Optimizing Inner Loop Copy
Mark E. Fenner
mfenner at gmail.com
Thu Aug 17 20:51:01 EDT 2006
Michael Spencer wrote:
> Mark E. Fenner wrote:
>
>>
>> and the copy is taking the majority (42%) of my execution time.
>> So, I'd like to speed up my copy. I had an explicit copy method that did
>> what was needed and returned a new object, but this was quite a bit
>> slower than using the standard lib copy.copy().
>>
> How are you measuring? It seems to me that your Rule.copy method is a lot
> faster than copy.copy:
>
> >>> r= Rule(range(100))
> >>> shell.timefunc(r.copy)
> 'copy(...) 36458 iterations, 13.71usec per call'
> >>> from copy import copy
> >>> shell.timefunc(copy, r)
> 'copy(...) 4498 iterations, 111.17usec per call'
<snip>
> Michael
Michael,
Thank you. I misinterpreted something somewhere ... the program is indeed
faster using Rule.copy. I need to look over the rest of my profiling data,
to see if I screwed up elsewhere as well.
So, how to optimize Rule.copy()?
Regards,
Mark
More information about the Python-list
mailing list