Why aren't copy and deepcopy in __builtins__?

Ethan Furman ethan at stoneleaf.us
Mon Mar 28 14:31:48 EDT 2011


John Ladasky wrote:
> On Mar 28, 2:25 am, Andrea Crotti <andrea.crott... at gmail.com> wrote:
>> I noticed some time ago in a program that needed speed that deepcopy in
>> particular is incredibly slow, but I guess is normal since it has to
>> copy every bit of the data structure.
> 
> That may be, but when it already takes several seconds for my neural
> network object to compute the output from a 100-element input
> sequence, the time that the occasional deepcopy call takes is
> insignificant to me.

A random thought that I haven't had time to test -- perhaps it would be 
quicker if you could save the existing object to a config object, modify 
the config object, then create a new instance of your neural net using 
that config object... obviously, it would take some work to get the 
initialization code going, but I would expect a speed increase from the 
result.

Of course, if that's not where your bottlenext is, we'll never know... 
(unless you're the curious type  ;).

Oh, and as for the original question, I think I've used the copy module 
once.

~Ethan~



More information about the Python-list mailing list