[Python-ideas] Have list/deque grow a copy() method

Fred L. Drake, Jr. fdrake at acm.org
Tue May 15 17:21:44 CEST 2007


On Tuesday 15 May 2007, Ian D. Bollinger wrote:
 > It would be nice if containers had a more consistent interface. The
 > standard idiom for copying a list has been L[:], but this isn't
 > polymorphic and perhaps arcane. Also, deques can only be copied with the
 > copy module's copy function (or calling the __copy__ wrapper directly);
 > thus using copy.copy is the only polymorphic way to copy a mutable
 > container. Additionally, having a consistent interface for mutable
 > containers may dovetail with the ABC PEP.

copy.copy() and copy.deepcopy() have always been the only polymorphic ways to 
create copies.  Is there any real motivation not to just use them?

I've not found that I need a way to copy arbitrary objects very often, and 
haven't found the occaissional import of the copy module to be an 
obstruction.  Are you needing to create lots of copies for some reason?


  -Fred

-- 
Fred L. Drake, Jr.   <fdrake at acm.org>



More information about the Python-ideas mailing list