Message80815
Copying an array.array object via the array constructor is some 100x
slower than using slicing or even converting the array to a string and
then passing that string to the array constructor.
Running the attached program on a 2.2GHz MacBook Pro (OSX 10.5.5, 4GB
RAM) produces this output:
$ python2.6 array_test.py
Constructor: 18.5617749691
Slice: 0.169251918793
String: 0.375015974045
From a look at arraymodule.c it seems that array_new() does not have a
special case for the array type and therefore uses the generic sequence
copy code rather than using memcpy(), like it can for slicing. |
|
Date |
User |
Action |
Args |
2009-01-30 12:33:28 | malcolmp | set | recipients:
+ malcolmp |
2009-01-30 12:33:26 | malcolmp | set | messageid: <1233318806.98.0.166527784762.issue5109@psf.upfronthosting.co.za> |
2009-01-30 12:33:24 | malcolmp | link | issue5109 messages |
2009-01-30 12:33:23 | malcolmp | create | |
|