views:

54

answers:

2

Hi all,

I was wondering whether objects serialized using CPython's cPickle are readable by using IronPython's cPickle; the objects in question do not require any modules outside of the built-ins that both Cpython and IronPython include. Thank you!

A: 

If you use the default protocol (0) which is text based, then things should work. I'm not sure what will happen if you use a higher protocol. It's very easy to test this ...

lazy1
Thanks for your answer. It's interesting that you emphasize "should", because right now I am indeed using the default protocol in both CPython and IronPython's cPickle, and I am getting "unexpected EOF" errors. Would you happen to know of any reasons why this may occur? My files are being read and written in modes 'rb' and 'wb', respectively.
JustOnePixel
Well should is certainly true module bugs. There are tests which include pickles from one version or another which work across runtimes. I've recently written some code which uses CPython's pickle output combined w/ IronPython's unpickler and had no problems. The one potential difference is IronPython may output unicode strings where CPython would output ASCII strings. But those should still pickle/unpickle across implementations. Can you possible cut down the problem to a smaller sample?
Dino Viehland
A: 

It will work because when you unpickle objects during load() it will use the current definitions of whatever classes you have defined now, not back when the objects were pickled.

IronPython is simply Python with the standard library implemented in C# so that everything emits IL. Both the CPython and the IronPython pickle modules have the same functionality, except one is implemented in C and the other in C#.

Aphex