This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author malcolmp
Recipients malcolmp
Date 2009-01-30.12:33:22
SpamBayes Score 6.410791e-08
Marked as misclassified No
Message-id <1233318806.98.0.166527784762.issue5109@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-01-30 12:33:28malcolmpsetrecipients: + malcolmp
2009-01-30 12:33:26malcolmpsetmessageid: <1233318806.98.0.166527784762.issue5109@psf.upfronthosting.co.za>
2009-01-30 12:33:24malcolmplinkissue5109 messages
2009-01-30 12:33:23malcolmpcreate