[Twisted-Python] Re: pickle apparently doesn't go with curry ...
Patrick K. O'Brien
pobrien at orbtech.com
Wed Nov 13 08:51:38 MST 2002
On Wednesday 13 November 2002 04:50 am, Michael Hudson wrote:
> jml at mumak.net (Jonathan M. Lange) writes:
> > >>> def foo():
> >
> > =2E.. pass
> > =2E..
> >
> > >>> import cPickle
> > >>> cPickle.dump(foo, open('testpickle', 'w'))
> > >>> bar =3D cPickle.load(open('testpickle'))
> >
> > I'd imagine this would work in most versions of python, given that
> > people have been pickling objects for countless generations.
>
> Oops, my mistake. But note that whats been pickled is a reference to
> __main__.foo, not the function object itself:
That's true about all code-like objects. The code itself doesn't get
pickled, only the state. The code is retrieved by the unpickler via the
references to the location of the code - the package name, module name,
class name, function name, etc.
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------
More information about the Twisted-Python
mailing list