Is it possible to compile Python natively (beyond pyc byte code)?

后端 未结 4 1702
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 16:39

I wonder if it is possible to create an executable module from a Python script. I need to have the most performance and the flexibility of Python script, without needing to run

4条回答
  •  日久生厌
    2021-02-02 17:18

    • There's pyrex that compiles python like source to python extension modules
    • rpython which allows you to compile python with some restrictions to various backends like C, LLVM, .Net etc.
    • There's also shed-skin which translates python to C++, but I can't say if it's any good.
    • PyPy implements a JIT compiler which attempts to optimize runtime by translating pieces of what's running at runtime to machine code, if you write for the PyPy interpreter that might be a feasible path.
    • The same author that is working on JIT in PyPy wrote psyco previously which optimizes python in the CPython interpreter.

提交回复
热议问题