[Pyrex] Passing objects back to Python?

Glenn grpython at sonic.net
Sun Feb 4 03:42:29 UTC 2007


It looks like the problem I was seeing was caused by the way the data  
array was indexed:


>>     for i from 0<=i<arr.dimensions[0]:
>>         print '  ',10.0*(<double*>arr.data)[0]
>>         els.append((<double*>arr.data)[0])
>>         arr.data = arr.data + arr.strides[0]

I adapted the code from an example I found and didn't think enough  
about what the code actually did.

Using
>
> for i from 0<=i<arr.dimensions[0]:
>         print '  ',(<double *>(arr.data + i*arr.strides[0]))[0]

doesn't seem to mangle the data portion of the ndarray.

Glenn



More information about the Pyrex mailing list