[Numpy-tickets] [NumPy] #340: ndpointer zeros part of 64-bit address

NumPy numpy-tickets at scipy.net
Thu Oct 12 08:49:46 CDT 2006


#340: ndpointer zeros part of 64-bit address
-----------------------------+----------------------------------------------
 Reporter:  albertstrasheim  |       Owner:  somebody   
     Type:  defect           |      Status:  new        
 Priority:  normal           |   Milestone:  1.0 Release
Component:  numpy.core       |     Version:  devel      
 Severity:  normal           |    Keywords:             
-----------------------------+----------------------------------------------
 SConstruct:
 {{{
 env = Environment()
 env.Replace(CCFLAGS=['-O0','-ggdb','-Wall','-ansi','-pedantic'])
 env.SharedLibrary('spfuncs',['spfuncs.c'])
 }}}

 C code:
 {{{
 #!c
 #include <stdio.h>
 void nnz(double *ary) {
     printf("ary = %p\n", (void*)ary);
 }
 }}}

 Python code:
 {{{
 #!python
 import numpy as N
 from ctypes import *
 from numpy.ctypeslib import ndpointer
 _libspfuncs = N.ctypeslib.load_library('libspfuncs', __file__)
 _libspfuncs.nnz.restype  = None
 A = N.eye((128))
 print A.ctypes.data_as(c_void_p)
 print hex(A.__array_interface__['data'][0])
 _libspfuncs.nnz.argtypes = [POINTER(c_double)]
 _libspfuncs.nnz(A.ctypes.data_as(POINTER(c_double)))
 _libspfuncs.nnz.argtypes = [ndpointer(dtype = N.float64)]
 _libspfuncs.nnz(A)
 }}}

 Output on 64-bit Linux with ctypes 1.0.0 and !NumPy r3317:

 {{{
 c_void_p(46912559644688)
 0x2aaaae740010
 ary = 0x2aaaae740010
 ary = 0xae740010
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/340>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list