INCF / nineml-python

A Python library for reading, parsing, validating and writing the 9ML (http://nineml.net) object model
Other
6 stars 10 forks source link

Should *Cloner methods be mapped to __copy__ or __deepcopy__ magic methods #12

Closed tclose closed 7 years ago

tclose commented 9 years ago

I can't work out whether *Cloner methods should be mapped to __copy__ or __deepcopy__ magic methods. In fact I am not sure the point of the cloner visitors are the first place, as __deepcopy__ should do the job no?

apdavison commented 9 years ago

I don't know without spending a lot more time with the code. I think the use of the Visitor pattern is possibly overkill here.

tclose commented 8 years ago

I just ran into a problem trying to deepcopy an object where it copied the document it belonged to as well, since all "document-level" objects contain a reference to the document they belong to. So having cloner methods is probably a good idea. Maybe all classes should implement a 'clone(self)' method for consistency between abstraction and user (property/state) layers.

tclose commented 7 years ago

I have decided that having separate deepcopy and cloner methods is probably a good idea