Message5438

Author kwatford
Recipients kwatford
Date 2010-01-14.19:04:57
SpamBayes Score 8.762604e-05
Marked as misclassified No
Message-id <1263495899.77.0.551478071392.issue1543@psf.upfronthosting.co.za>
In-reply-to
Content
>>> 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:05:00kwatfordsetrecipients: + kwatford
2010-01-14 19:04:59kwatfordsetmessageid: <1263495899.77.0.551478071392.issue1543@psf.upfronthosting.co.za>
2010-01-14 19:04:58kwatfordlinkissue1543 messages
2010-01-14 19:04:57kwatfordcreate