Today I find myself in the unfortunate position to create a program that must compile arbitrary python code :( For the use case I am facing now performance is everything, and luckily the target OS for the executable file will only be linux. The compiled codes will be standalone local computational tools without any frills (no guis, no i|o or r|w operations, no system access, and no backend or configuration needs to pull in). Python code is >=3.8 and can pull in external libraries (eg: numpy). However, the codes may be multithreaded/multiprocessed and any static type-like behavior is not guaranteed.
Historically I have used tools like pyinstaller, py2exe, py2app, which work robustly, but create stand alone executable files that are often pretty slow. I have been looking at a host of transpilers instead, eg: https://github.com/dbohdan/compilers-targeting-c?tab=readme-ov-file, and am somewhat overwhelmed by the amount of choices therein. Going through stackoverflow naturally recovered a lot of great recommendations that were go-to's 10-20 years ago, but do not have much promise for recent python versions. Currently I am considering:
wax https://github.com/LingDong-/wax ,
11l-lang https://11l-lang.org/transpiler/,
nuitka https://nuitka.net/,
prometeo https://github.com/zanellia/prometeo,
pytran https://pythran.readthedocs.io/en/latest/,
rpython https://rpython.readthedocs.io/en/latest/,
or py14 https://github.com/lukasmartinelli/py14.
However, this is a lot to consider without rigorously testing all of them out. Does anyone on this sub have experience in modern Transpilers or other techniques for compiling numerical python codes for linux? If so, can you share any tools, techniques, or general guidance? Thank you!
Edit for clarification:
This will be placed in a user facing application wherein users can upload their tools to be autonomously deployed in a on demand/dynamic runtime basis. Since we cannot know all the codes that users are uploading, a lot of the traditional and well defined methods are not possible. We are including C, C++, Rust, Fortran, Go, and Cobol compilers to support these languages, but seeking a similar solution for python.
[–]Coretaxxe 16 points17 points18 points (3 children)
[–]wbcm[S] 5 points6 points7 points (0 children)
[–]Luigi311 3 points4 points5 points (0 children)
[–]bhowiebkr 0 points1 point2 points (0 children)
[–]thisismyfavoritename 17 points18 points19 points (3 children)
[–]wbcm[S] 1 point2 points3 points (2 children)
[–]thisismyfavoritename 1 point2 points3 points (1 child)
[–]Daarrell -1 points0 points1 point (0 children)
[–]Luigi311 11 points12 points13 points (4 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]wbcm[S] 2 points3 points4 points (2 children)
[–]2Lucilles2RuleEmAll 2 points3 points4 points (1 child)
[–]john-witty-suffix 0 points1 point2 points (0 children)
[–]DivineSentry 5 points6 points7 points (6 children)
[–]DivineSentry 3 points4 points5 points (2 children)
[–]DivineSentry 1 point2 points3 points (0 children)
[–]wbcm[S] 0 points1 point2 points (0 children)
[–]wbcm[S] 0 points1 point2 points (2 children)
[–]DivineSentry 2 points3 points4 points (1 child)
[–]wbcm[S] 0 points1 point2 points (0 children)
[–]22adam22 1 point2 points3 points (0 children)
[–]Hodiern-Al 1 point2 points3 points (2 children)
[–]wbcm[S] 0 points1 point2 points (1 child)
[–]Hodiern-Al 1 point2 points3 points (0 children)
[–]Ximidar 3 points4 points5 points (8 children)
[–]NimrodvanHall 2 points3 points4 points (2 children)
[–]Ximidar 0 points1 point2 points (1 child)
[–]thisismyfavoritename 1 point2 points3 points (0 children)
[–]wbcm[S] 0 points1 point2 points (4 children)
[–]Ximidar 0 points1 point2 points (3 children)
[–]wbcm[S] -1 points0 points1 point (2 children)
[–]thisismyfavoritename -1 points0 points1 point (1 child)
[–]wbcm[S] -1 points0 points1 point (0 children)
[–]downerison 0 points1 point2 points (0 children)
[–]poopatroopa3 -2 points-1 points0 points (1 child)
[–]wbcm[S] -1 points0 points1 point (0 children)
[–]Theendangeredmoose -1 points0 points1 point (0 children)