pickling lambdas?

John J. Lee jjl at pobox.com
Sat Jan 3 18:44:01 EST 2004


gongli at cutey.com (gong) writes:

> i would like to pickle a lambda; according to the library docs in 2.3,
> i believe this shouldnt be possible, since a lambda is not a function
> defined at the top level of  a module (?)

Yes.


> however, upon google searching for "python lambda pickle" i find 2
> posts, one including gvr, which apparently demonstrate that this was
> being attempted and even suggest that it is feasible.  has this become
[...]

No, read it again.  What you found was Guido figuring out how to
*prevent* people pickling lambdas.  Functions are pickled by saving
the function name.  Lambdas have no function name, so pickle complains
if you try to pickle them.


John



More information about the Python-list mailing list