Question on compiled code when embedding Python in C++

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Dec 3 23:36:07 EST 2007


En Tue, 04 Dec 2007 00:54:57 -0300, Borse, Ganesh  
<ganesh.borse at credit-suisse.com> escribió:

> When we compile a Python code using functions such as Py_CompileString  
> or any other similar compile function, what will be the resulting  
> executable code?
> Will it be byte code somewhat like the byte code of Java?
> Or it will be the same binary code like the once generated by  
> C/C++ compilers from the source code?

For CPython, the resulting bytecode consist of instructions for a virtual  
machine, like Java.
I believe Jython compiles Python code into Java bytecode and executes  
using the Java VM.

> Are these code evaluations recommended for the performance intensive  
> actions in C++ program?

If you only care about speed, maybe Python isn't the right tool to use in  
the first place.

There are some performance tips here:  
<http://wiki.python.org/moin/PythonSpeed/PerformanceTips> and you can use  
tools like Psyco, Pyrex and ShedSkin to improve performance dramatically.

-- 
Gabriel Genellina




More information about the Python-list mailing list