[IronPython] Serializing IronPython classes
deus.verus at gmail.com
Tue Oct 7 04:36:22 CEST 2008
Thanks for the heads up, however trying to use cPickle, I still get the
error saying that the child class is not marked as serializable..?
On 10/7/08, Dino Viehland <dinov at microsoft.com> wrote:
> I would strongly encourage you to use cPickle or pickle instead of .NET
> serialization. In 2.0 all .NET serializable types can also be pickled –
> they define __reduce_ex__ which handles this.
> First off we should be setting the serializable bit on subclasses that are
> serializable – that's just a bug that we're not doing that. But once we've
> done that the problem w/ .NET serialization is that ultimately we need a
> static method or type that we can point at that does the deserialization.
> For a user defined type in Python we will need to be able to deserialize the
> type, the module the type lives in, and presumably even the ScriptRuntime
> which holds the module. Pickle handles this by serializing the module &
> type name but w/o a ScriptRuntime we couldn't even get at that. We might
> have been able to require a ScriptRuntime to be smuggled in the
> StreamingContext but it's not clear that it would work well.
> So if you really want .NET serialization we can fix the bug – but you'll
> need to implement ISerializable and figure out some way to deal getting the
> class, module, and runtime information saved/restored yourself.
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Serge
> *Sent:* Sunday, October 05, 2008 9:24 PM
> *To:* users at lists.ironpython.com
> *Subject:* [IronPython] Serializing IronPython classes
> I've run into problems with serialization. I have a serializable class
> defined in C# which gets extended from IP, however when I try to serialize a
> collection of both parent and child instances, I get an exception saying
> that the IP generated class is not marked as serializable.
> With the lack of attributes, I am guessing I must do something else to
> enable serialization?
> Regards, Serge.
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users