Update with pickle
Matteo Dell'Amico
della at toglimi.linux.it
Tue May 25 14:19:18 EDT 2004
Nicolas Fleury wrote:
>> I don't get what you want to do. Can you explain yourself better? What
>> do you mean by "updating" an object?
> Use the same reference instead of creating a new instance. Basically
> making pickle call __init__ of an existing object. The best solution I
> see for now is to copy the __dict__ of the new object to the existing
> one. I want to update the content of an object with a dumped object of
> the same type so that all reference to existing object are still valid.
I think it's not possible to do automatically. Beware of copying
__dict__, since starting with python 2.2, it's possible to have data
that doesn't reside in __dict__, for instance when using __slots__.
I guess you have to find a way to encapsulate information, and maybe a
proxy could be OK for you (I can't find the recipe in the Python
Cookbook right now, since it appears to be down). That way, you could
keep all references to the proxy, and change the encapsulated data when
you need it.
--
Ciao,
Matteo
More information about the Python-list
mailing list