Christopher Barker wrote: > Lars Friedrich wrote: > >> I would like to work with some data using python/numpy. The data is >> generated with C. To bring the data from C to python, I would like to >> use ctype. I am using python 2.4.3 on a windows-System. >> >> To accomplish the described task, I have the following plan. Please tell >> me, if this is possible, respectively if there is a better way. >> >> 1) In C, I write a .dll, that has a function >> int foo(PyObject *arg) >> > > I'm a bit confused here. I thought the primary point of ctypes was to be > able to access existing, non-python-aware dlls from Python without > writing C code. > > In this case, you're writing a dll that understands PyObjects (or, I > assume, a particular PyObject -- a numarray). Why not just forget ctypes > and write a regular old extension? > > See Albert's post up thread. Agreed, if he was going to go to the trouble of using the Py C API then he didn't really need ctypes. What the original poster wanted (Im assuming) was something much simpler like
int foo(int* x) as Albert suggested, and then use the new numpy ctypes atrributes and ctypes 'argtypes' type mapping facility to pass the data contained in the py object into a simple routine. That then, is the advantage of ctypes. Mark ------------------------------------------------------------------------- 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