[Python-Dev] implementation of copy standard lib

Ron Adam rrr at ronadam.com
Tue Aug 16 20:52:24 CEST 2005

Simon Brunning wrote:

> On 8/14/05, Martijn Brouwer <e.a.m.brouwer at alumnus.utwente.nl> wrote:
>>After profiling a small python script I found that approximately 50% of
>>the runtime of my script was consumed by one line: "import copy".
>>Another 15% was the startup of the interpreter, but that is OK for an
>>interpreted language. The copy library is used by another library I am
>>using for my scripts. Importing copy takes 5-10 times more time that
>>import os, string and re together!
>>I noticed that this lib is implemented in python, not in C. As I can
>>imagine that *a lot* of libs/scripts use the copy library, I think it
>>worthwhile to implement this lib in C.
>>What are your opinions?
> I think that copy is very rarely used. I don't think I've ever imported it.
> Or is it just me?

I use copy.deepcopy() sometimes, and more often [:] with lists. 
Dictionary objects have a copy method.  All non mutable objects are copies.

I too have wondered why copy isn't a builtin, and yet some builtin 
objects do make copies.


More information about the Python-list mailing list