15 Dec
2009
15 Dec
'09
4:59 p.m.
Vitor Bosshard <algorias@...> 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.