Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can Python be compiled to machine code, C or some other language?

0
10 Posted

Can Python be compiled to machine code, C or some other language?

0

Not easily. Python’s high level data types, dynamic typing of objects and run-time invocation of the interpreter (using eval() or exec) together mean that a “compiled” Python program would probably consist mostly of calls into the Python run-time system, even for seemingly simple operations like x+1. Several projects described in the Python newsgroup or at past Python conferences have shown that this approach is feasible, although the speedups reached so far are only modest (e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated that in combination with whole-program analysis, speedups of 1000x are feasible for small demo programs. See the proceedings from the 1997 Python conference for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual machine.

0

Not easily. Python’s high level data types, dynamic typing of objects and run-time invocation of the interpreter (using eval or exec) together mean that a “compiled” Python program would probably consist mostly of calls into the Python run-time system, even for seemingly simple operations like x+1. Several projects described in the Python newsgroup or at past Python conferences have shown that this approach is feasible, although the speedups reached so far are only modest (e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated that in combination with whole-program analysis, speedups of 1000x are feasible for small demo programs. See the proceedings from the 1997 Python conference for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual machine.

0
10

Not easily. Python’s high level data types, dynamic typing of objects and run-time invocation of the interpreter (using eval() or exec) together mean that a “compiled” Python program would probably consist mostly of calls into the Python run-time system, even for seemingly simple operations like x+1. Several projects described in the Python newsgroup or at past Python conferences have shown that this approach is feasible, although the speedups reached so far are only modest (e.g. 2x). Jython uses the same strategy for compiling to Java bytecode. (Jim Hugunin has demonstrated that in combination with whole-program analysis, speedups of 1000x are feasible for small demo programs. See the proceedings from the 1997 Python conference for more information.) Internally, Python source code is always translated into a bytecode representation, and this bytecode is then executed by the Python virtual machine. In order to avoid the overhead of repeatedly parsing and translating modules that rarely

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123