Load Python Scripts from Memory

Alex Martelli aleax at aleax.it
Tue Nov 11 06:25:35 EST 2003


John J. Lee wrote:

> Alex Martelli <aleax at aleax.it> writes:
> 
>> Dean Ellis wrote:
> [...]
>> Run this code once, e.g. at program startup, and assuming the
>> get_pickled_... functions know how to get a pickled sourcecode
>> string or codeobject from wherever, the rest should work (I'm
> [...]
> 
> Why would you want to pickle the source for transit over the network?

Just for uniformity with the codeobject.  The OP had specified that
the incoming code "might be" compiled (implying it might also not be),
and pickle (or marshal, etc) is one simple way to let either source
code _or_ a codeobject be treated the same way on arrival (unpickle,
or unmarshal, then exec whatever has arrived).


Alex





More information about the Python-list mailing list