Issue1612

classification
Title: array.array copies strings instead of using them to back the new array
Type: Severity: minor
Components: Core Versions: Jython 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: akong, doublep, fwierzbicki, mcieslik, zyasoft
Priority: low Keywords:

Created on 2010-05-18.18:33:04 by mcieslik, last changed 2013-02-26.17:33:07 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
profile_array.py mcieslik, 2010-05-18.18:33:03
Messages
msg5769 (view) Author: Marcin (mcieslik) Date: 2010-05-18.18:33:03
It takes ~ 300x longer to create instances of array.array in Jython2.5.1 vs Python2.6 and Python3.1

e.g. the following: 
from array import array
array('b', large_string)

$ python2.6 profile_array.py 
0.0104711055756
$ python3.1 profile_array.py 
0.00699281692505
$ jython profile_array.py 
3.00600004196
$ jython --version
Jython 2.5.1
msg5770 (view) Author: (doublep) Date: 2010-05-19.11:21:16
Did you measure total program time?
msg5771 (view) Author: Marcin (mcieslik) Date: 2010-05-19.12:09:26
The 3s of jython profile_array.py do **NOT** include the JVM start-up time, so it is 'wall-clock' time of the loop.

this is what is in the attached script:
start = time()
for i in range(10000):
    array('b', large_string)
stop = time()
msg6186 (view) Author: Jim Baker (zyasoft) Date: 2010-10-17.17:21:48
The problem here is that we copy the string. In 2.6 this can be avoided by supporting a string to back an array. This can (and should) be part of a general support for memoryview.
msg6187 (view) Author: Jim Baker (zyasoft) Date: 2010-10-17.17:24:14
better title - "Jython ____" is just noise here
History
Date User Action Args
2013-02-26 17:33:07fwierzbickisetnosy: + fwierzbicki
2013-02-25 19:04:22fwierzbickisetversions: + Jython 2.7, - 2.5.1
2010-10-17 17:24:15zyasoftsetmessages: + msg6187
title: Jython copies strings instead of using them to back an array -> array.array copies strings instead of using them to back the new array
2010-10-17 17:21:49zyasoftsetpriority: low
nosy: + zyasoft
messages: + msg6186
title: Jython ~300x slower on array.array instance creation -> Jython copies strings instead of using them to back an array
2010-05-23 00:10:01akongsetnosy: + akong
2010-05-19 12:09:26mciesliksetmessages: + msg5771
2010-05-19 11:21:17doublepsetnosy: + doublep
messages: + msg5770
2010-05-18 18:33:04mcieslikcreate