Re: Serializing Python compiled code.

2007-12-10 Thread Tim Roberts
[EMAIL PROTECTED] 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, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Serializing Python compiled code.

2007-12-09 Thread renjipanicker
Hi everyone,

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?

Please do reply.

Thanks,
-/renji
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Serializing Python compiled code.

2007-12-09 Thread Steve Howell
--- [EMAIL PROTECTED] 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?
 


This might be too coarse for you, but you could
serialize the .pyc files that get created from your
modules.  If you drop a .pyc file into a directory,
and you make sure that you don't have a corresponding
.py file of the same basename, and new date, in the
directory, then Python will still execute it.

This is a bit of a gotcha of Python for naive users,
but this feature helps in use cases like yours, where
you don't want to pay the lexing step, and for
whatever reason, you don't want to simply use the file
system as your store for code.


  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
-- 
http://mail.python.org/mailman/listinfo/python-list