[Python-Dev] Pickling instances of nested classes
Walter Dörwald
walter at livinglogic.de
Thu Mar 31 16:45:08 CEST 2005
Samuele Pedroni wrote:
> Walter Dörwald wrote:
>
>> [User cases for pickling instances of nested classes]
>> So is this change wanted? useful? implementable with reasonable
>> effort? Or
>> just not worth it?
>
> notice that in this cases often metaclasses are involved or could easely
> be, so if pickling would honor __reduce__ or __reduce_ex__ on
> metaclasses (which right now it doesn't treating their instances as
> normal classes) one could roll her own solution without the burden for
> the language of implementing pickling of nested classes in general, so I
> think that would make more sense, to add support to honor
> __reduce__/__reduce_ex__ for metaclasses.
Sorry, I don't understand: In most cases it can be possible to
work around the nested classes problem by implementing custom pickling
functionality (getstate/setstate/reduce/reduce_ex). But it is probably
impossible to implement this once and for all in a common base class,
because there's no way to find the real name of the nested class (or any
other handle that makes it possible to retrieve the class from the
module on unpickling).
And having the full name of the class available would certainly help in
debugging.
Bye,
Walter Dörwald
More information about the Python-Dev
mailing list