Serializing Python compiled code.

Tim Roberts timr at probo.com
Tue Dec 11 01:59:45 EST 2007


renjipanicker at gmail.com wrote:
>
>In a C++ application having a Python interpreter embedded, is it
>possible to compile a small Python snippet into object code and
>serialize the compiled object code to, for example, a database? I am
>exploring the possibility of writing a data driven application, where
>small-sized object code can be read from a database and executed.
>Keeping aside all other considerations such as security, etc for a
>moment, is this feasible?

The biggest problem, in my view, is that the compiled object code won't
work with any other version of Python, or with versions where the compiler
was built with other options, or possibly even on other processors with the
same version.  The nice thing about a database server is that you can use
it from different computers without worrying about versions or processors.

Compilation is not that expensive.  Why not just store the raw code
snippets?
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list