[Twisted-Python] Large project (IMS) architecture

Steve Waterbury waterbug at beeblebrox.gsfc.nasa.gov
Thu Jan 16 15:32:58 EST 2003


"Patrick K. O'Brien" wrote:
> 
> On Thursday 16 January 2003 12:01 pm, Steve Waterbury wrote:
> >
> > And jelly does nested objects, which Pickle can't.
> 
> I'm not sure what you mean by that. Could you explain in what way Pickle
> can't handle nested objects? Thanks.

Sorry -- I didn't mean "nested objects", but nested 
functions of certain kinds, such as lambdas or 
curried functions.  E.g.:

>>> import pickle 
>>> f = lambda x: x in (1,2,3)
>>> pf = pickle.dumps(f)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.2/pickle.py", line 978, in dumps
    Pickler(file, bin).dump(object)
  File "/usr/local/lib/python2.2/pickle.py", line 115, in dump
    self.save(object)
  File "/usr/local/lib/python2.2/pickle.py", line 225, in save
    f(self, object)
  File "/usr/local/lib/python2.2/pickle.py", line 519, in save_global
    raise PicklingError(
pickle.PicklingError: Can't pickle <function <lambda> at 0x8161924>: it's not found as __main__.<lambda>
>>> from twisted.spread.jelly import jelly, unjelly
>>> jf = jelly(f)
>>> jf
['function', '__main__.<lambda>']
>>> newf = unjelly(f)
>>> newf(1)
1
>>> newf(4)
0

-- Steve.




More information about the Twisted-Python mailing list