numpypy buffer interface for slices different from numpy
Hi group! I stumbled upon a difference in numpypy's ndarray buffer interface. If I take the address of the data of a slice in numpy, I get a pointer to the first element in the slice. In numpypy I get a pointer to the data I took the slice from. I wonder if this is a bug or deliberate? If it's a bug, it's probably merely an omission of adding the offset to the data pointer. Here's what I observed: $ pypy Python 2.7.3 (aa7b56060ddd, Apr 22 2013, 22:03:12) [PyPy 2.0.0-beta2 with GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. And now for something completely different: ``PyPy 1.2 released - http://pypy.org/''
import numpypy as np a=np.zeros(10) a.__array_interface__['data'][0] -1220095968 a[2:].__array_interface__['data'][0] -1220095968 <<<<<<<< same value
$ python Python 2.7.3 (default, Apr 10 2013, 05:46:21) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np a=np.zeros(10) a.__array_interface__['data'][0] 162282152 a[2:].__array_interface__['data'][0] 162282168 <<<<<<<<<<< different value
with regards Kay F. Jahnke
On Tue, Apr 23, 2013 at 5:12 PM, Kay F. Jahnke <_kfj@yahoo.com> wrote:
Hi group!
I stumbled upon a difference in numpypy's ndarray buffer interface. If I take the address of the data of a slice in numpy, I get a pointer to the first element in the slice. In numpypy I get a pointer to the data I took the slice from. I wonder if this is a bug or deliberate? If it's a bug, it's probably merely an omission of adding the offset to the data pointer. Here's what I observed:
it's a bug, please file in a bug on bugs.pypy.org so we don't forget (even better submit a patch, but a bug is good too) Cheers, fijal
$ pypy Python 2.7.3 (aa7b56060ddd, Apr 22 2013, 22:03:12) [PyPy 2.0.0-beta2 with GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. And now for something completely different: ``PyPy 1.2 released - http://pypy.org/''
import numpypy as np a=np.zeros(10) a.__array_interface__['data'][0] -1220095968 a[2:].__array_interface__['data'][0] -1220095968 <<<<<<<< same value
$ python Python 2.7.3 (default, Apr 10 2013, 05:46:21) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np a=np.zeros(10) a.__array_interface__['data'][0] 162282152 a[2:].__array_interface__['data'][0] 162282168 <<<<<<<<<<< different value
with regards Kay F. Jahnke _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
participants (2)
-
Kay F. Jahnke
-
Maciej Fijalkowski