Update with pickle

Nicolas Fleury nid_oizo at yahoo.com_remove_the_
Wed May 26 09:35:30 EDT 2004


Stefan Seefeld wrote:

> Hi there (,hi Nicolas !),

> ...I'm still lost: how is this interface-enriched declaration helping
> in the task to retrieve ('internalize') an object's state from a pickle ?

Hi Stefan,
You're right, the example shows how to copy and it creates a new 
reference, so it doesn't help in the problem (I realized it when going 
back home yesterday).

> Looking again into the docs for the pickle protocol, I wonder whether there
> isn't any place in the __init__/__reduce__/__setstate__ magic to throw in
> some meta-programming (i.e. an intelligent metaclass doing the job), or 
> providing
> a clever __new__ operator that doesn't return a new object but an 
> existing one,
> etc., etc.

I just added a feature request on sf to have an updating load function 
in pickle.  My preferred solution for now might still be the copy of 
__dict__ (I could copy slots also), it's simple and not intrusive (using 
proxies is, even if less a hack).  However, the cleanest solution would 
be to implement your solution, but I have no idea how to do it for now.

Regards,
Nicolas



More information about the Python-list mailing list