New submission from Malcolm Purvis <malcolm@purvis.id.au>:
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.
----------
components: Library (Lib)
files: array_test.py
messages: 80815
nosy: malcolmp
severity: normal
status: open
title: array.array constructor very slow when passed an array object.
type: performance
versions: Python 2.6
Added file: http://bugs.python.org/file12893/array_test.py
_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5109>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
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.
----------
components: Library (Lib)
files: array_test.py
messages: 80815
nosy: malcolmp
severity: normal
status: open
title: array.array constructor very slow when passed an array object.
type: performance
versions: Python 2.6
Added file: http://bugs.python.org/file12893/array_test.py
_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5109>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com