Issue1543

classification
Title: PyArray fails to clean up pre-allocated space
Type: behaviour Severity: normal
Components: Core Versions: 2.5.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: kwatford
Priority: Keywords:

Created on 2010-01-14.19:04:59 by kwatford, last changed 2010-01-14.19:04:59 by kwatford.

Messages
msg5438 (view) Author: Ken Watford (kwatford) Date: 2010-01-14.19:04:57
>>> from jarray import array
>>> from java.lang import Object
>>> x = array([0,1,2], Object)
>>> x.append(3)
>>> x
array(java.lang.Object, [0, 1, 2, 3])
>>> y = array([x], Object)
>>> y
array(java.lang.Object, [array(java.lang.Object, [0, 1, 2, 3, None, None, None])])
>>> x == y[0]
False

The append on x causes some extra array space to be allocated, but apparently the end of the array isn't remembered when assigned into y. However, if we use PyObject instead of Object...

>>> x = array([0,1,2], object)
>>> x.append(3)
>>> x
array(org.python.core.PyObject, [0, 1, 2, 3])
>>> y = array([x], object)
>>> y
array(org.python.core.PyObject, [array(org.python.core.PyObject, [0, 1, 2, 3])])
>>> x == y[0]
True

In case it matters:
$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)
History
Date User Action Args
2010-01-14 19:04:59kwatfordcreate