list IndexError

Scott David Daniels Scott.Daniels at Acm.Org
Sun Dec 26 16:28:33 EST 2004


Ishwor wrote:
> On Thu, 23 Dec 2004 13:57:55 -0300, Batista, Facundo
> <FBatista at unifon.com.ar> wrote:
>>#- True, true.  Maybe you could lobby for copy as a builtin in 
>>#- Python 3000? 
>>
>>That's a good idea to me. But copy() as a builtin is not clear if it's
>>shallow or deep. 
> 
> IMHO its preferable to use shallow one as the built-in because deep is
> expensive op. for CPU. ~;-)
"deepcopy" is an operation that is less well defined than shallow copy
anyway (and hence shouldn't be a default).  Objects representing
constants may contain a cache (for example) as an efficiency measure,
and "deepcopy" needn't copy such objects.  The only way to safely
do deepcopy is to copy down to immutables, but usually there is a
shallower and faster implementation that depends on application
semantics.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list