[Python-ideas] Being able to specify

Ram Rachum cool-rr at cool-rr.com
Tue Dec 15 17:59:57 CET 2009


Vitor Bosshard <algorias at ...> writes:
> Deepcopy is a very simple operation conceptually, there's no need to
> make it more complicated. How about implementing __deepcopy__ in your
> world state objects? Specify attributes that don't need copying. You
> can even use the Persistent class to signal that. Something like this
> (untested!):
> 
> def __deepcopy__(self):
>   new = self.__class__()
>   for k,v in self.__dict__.iteritems():
>     setattr(new, k, v if isinstance(v, Persistent) else deepcopy(v))
>   return new
> 
> Vitor


And what happens when State refers to another object which refers to a
Persistent?

Ram.









More information about the Python-ideas mailing list