How to marshal a function?
logiplexsoftware at earthlink.net
Thu Nov 15 00:38:42 CET 2001
On Wednesday 14 November 2001 14:53, François Pinard wrote:
> I did not even try `pickle' for that, after the documentation (printed at
> 1.5.2 time) insists that `pickle' has no representation for code objects.
> If you examine `pc', you will have some difficulty to believe that it
> actually conveys the function definition. It probably only holds a
> reference to the name. Oh, it does works if I do everything in a single
> Python session, because `f' is already defined. But if I save `pc' to
> disk and reload it in a fresh Python session, the `pickle.loads(pc)'
> SystemError: Failed to import class f from module __main__
> So, I would not think that `pickle' is a solution.
How embarrassing. I dug around and found the code I had used, and sure
enough, I was using marshal. Further, due to the way I was using the code
(the compiled bytecode was fairly self-contained) I never encountered the
limitations you mention.
Still, I think there must be a way around this... I will look further.
BTW, are you aware that you are double-posting?
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308
More information about the Python-list