Can code objects outlive the interpreter that created them?

Andy Jost Andrew.Jost at synopsys.com
Tue Jun 15 16:51:28 EDT 2010


Hi,

I'm working on an application program that embeds Python using the C-API. Sometimes, I need to call functions written in pure Python from the C code, so I use Py_CompileString and PyEval_EvalCode.

I would like to avoid compiling the same code over and over by storing the result of Py_CompileString in a static variable, however, the application does sometimes restart the Python interpreter.

My question: is the PyCodeObject * returned from Py_CompileString still valid after Python is restarted?

Andy Jost
Sr. R&D Engineer
Silicon Engineering Group
Synopsys, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100615/e5c7b999/attachment.html>


More information about the Python-list mailing list