[Python-Dev] Re: [ python-Bugs-416670 ] MatchObjects not deepcopy()able

M.-A. Lemburg mal@lemburg.com
Fri, 27 Apr 2001 11:20:59 +0200


Fredrik Lundh wrote:
> 
> tim wrote:
> > It's a std way to get a clone of an object, and when you don't want mutations
> > of the clone to have any effect on the original (or vice versa).  Perhaps if
> > I call it the Clone Pattern, people will assume that makes it a good thing
> > and cut that part of the debate mercifully short <wink>.
> 
> which leads to a followup question: the current approach
> seems to be to hack the copy.py file for each and every
> type.  imo, that's rather unpythonic, and also introduces
> lots of unnecessary module dependencies.
> 
> time to add a __clone__ slot?
> 
> or could someone who knows what he's doing here address
> this comment in copy.py:
> 
>     # XXX need to support copy_reg here too...

All you have to do is implement the copy protocol (ie. .copy())
for the type/class in question.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Pages:                           http://www.lemburg.com/python/