[Ironpython-users] Understanding CPython and IronPython linkage

Dino Viehland dinov at microsoft.com
Thu Feb 23 03:26:19 CET 2012


That's actually only an incompatibility w/ marshal, not pickle.  Functions are always
pickled by reference (module name + function name) and if you try and pickle
a code object directly it fails:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle
>>> cPickle.dumps((lambda x:42).func_code)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle code objects
>>>

> -----Original Message-----
> From: ironpython-users-bounces+dinov=microsoft.com at python.org
> [mailto:ironpython-users-bounces+dinov=microsoft.com at python.org] On
> Behalf Of Jeff Hardy
> Sent: Wednesday, February 22, 2012 2:48 PM
> To: Lucas Vickers
> Cc: ironpython-users at python.org
> Subject: Re: [Ironpython-users] Understanding CPython and IronPython linkage
> 
> On Wed, Feb 22, 2012 at 2:28 PM, Lucas Vickers <lucasvickers at gmail.com>
> wrote:
> > Rhino3d uses IronPython to let us control low level .net Rhino APIs
> > using python. Super cool. But what about pickle do u need to watch out for?
> 
> Pickled code objects.
> 
> - Jeff
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users




More information about the Ironpython-users mailing list