How to run codeobjects in Python?

Joonas Paalasmaa joonas at olen.to
Fri Jul 13 09:13:38 EDT 2001


Vesselin Peev wrote:
> 
> Can anyone tell me how to use the so called "code objects" in Python, for
> example the ones created via
> 
> PyObject* Py_CompileString(char *str, char *filename, int start)
> 
> There's no explanation on the matter that I can find.
> 
> All I want to do is to execute different precompiled python code blocks from
> a C program (I have already embedded Python). I could make do without
> bytecode but then the speed would be much less.

Do you mean this?

>>> code = compile("print 'Python!'","<string>","exec")
>>> exec code
Python!
>>>



More information about the Python-list mailing list