> What's might be happening here is that a.ctypes.data is in fact being passed > to your function via ctypes's from_param magic (check the ctypes tutorial > for details). > > In [10]: x = N.array([]) > > In [11]: x.ctypes.data > Out[11]: c_void_p(15502816) > > In [12]: x._as_parameter_ > Out[12]: 15502816 > OK, I did not know about x.ctypes.data...
> So what's probably happening here is that you already have a pointer to the > array's data which you then cast to a PyArrayObject pointer. Dereferencing > myPtr->data is looking for a pointer inside the array's data, which contains > zeros. I understand. > - look at ctypes's PyDLL option if you want to pass around Python objects ??? > - Write your function as: > > int foo(int* x); > > Then do something like this: > > x = N.array([...], dtype=N.intc) > mydll.foo.restype = None > mydll.foo.argtypes = [POINTER(c_int)] > mydll.foo(x.ctypes.data) I did that, and it worked fine for me. Thank you very much! This is really great. Lars ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion