Elegant copy-by-value

Robin Becker robin at jessikat.fsnet.co.uk
Sun Jan 12 11:29:31 CET 2003


In article <3E20CA0F.E2C07F4E at engcorp.com>, Peter Hansen
<peter at engcorp.com> writes
>Martin Christensen wrote:
>> 
>> Python usually uses copy-by-reference. This is all good and well, but
>> sometimes we want copy-by-value. For a long time now I've been using
>> copy() or deepcopy(), depending on the circumstances, from the copy
>> module. Is there no more simple and elegant way of doing this? It
>> seems strange that one should have to import a module to so something
>> as simple as a copy-by-value. 
>
>No one could call copy-by-value in Python "simple" who has looked at 
>the source for it.
>
>Have you looked at copy.py?  If you haven't, take a peek now and then
>come back and try the question again. ;-)
>
>-Peter
well I did a C extension that implemented most things (up to the new
stuff in 2.2) and you're right it's not at all obvious. I suppose
there's not a lot of interest in faster copy/deep copy; at least no one
has complained that I haven't extended it to cover new style classes.

This seems like an obvious candidate for speeding up, but there's not a
lot of interest in it.
-- 
Robin Becker




More information about the Python-list mailing list