[IronPython] Pickle bug

Christian Muirhead christian.muirhead at resolversystems.com
Thu Sep 4 16:41:46 CEST 2008


Michael Foord wrote:
> Pickle on IronPython doesn't preserve sufficient information to unpickle 
> floats accurately:
> 
> CPython:
>  >>> a = 1 /3.0
>  >>> import cPickle as pickle
>  >>> pickle.loads(pickle.dumps(a)) == a
(Michael meant to say that this was True)
> 
> IronPython:
>  >>> import cPickle as pickle
>  >>> a = 1 /3.0
>  >>> pickle.loads(pickle.dumps(a)) == a
> False
> 
> This is actually causing us numerical errors in Resolver One. CPython is 
> actually very careful about its string representation of floats so that 
> this is possible.

I think it's because IP cPickle is relying on the .NET Double.ToString 
which isn't as truthful as cPython's repr.

The issue's covered here: http://www.python.org/doc/current/tut/node16.html

xtian


-- 
Christian Muirhead
Resolver Systems
christian.muirhead at resolversystems.com
We're hiring! http://www.resolversystems.com/jobs/


Resolver Systems Ltd
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company 
number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK



More information about the Ironpython-users mailing list