Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-18 Thread Jose Martin
Thanks everyone for all the comments! It helped to understand better the advantages/disadvantages of the various options to interact with C. Jose. --- On Sat 05/17, Bill Spotz < [EMAIL PROTECTED] > wrote: Just to make sure the original question gets answered, yes, numpy.i avoids copies as

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Bill Spotz
Just to make sure the original question gets answered, yes, numpy.i avoids copies as much as possible. A special case is when your C code provides you with a view of its internal data and does not require any memory to be allocated by the (python) user. This can be dangerous, but if it is y

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Brian Granger
On Sat, May 17, 2008 at 8:35 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > On Sat, May 17, 2008 at 9:30 PM, Brian Granger <[EMAIL PROTECTED]> wrote: >> >> Please correct any new errors I have introduced. >> > > Thanks Brian, I think that's a fair representation. > > Minor typo "course grained" -> "c

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Brian Granger
Jose, As you can see, people have different preferences for wrapping C/C++ code. I should also mention that one of the easiest methods if numpy arrays are involved is ctypes. numpy arrays already have more-or-less built-in support for talking to ctypes. Details are available here: http://www.s

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Nathan Bell
On Sat, May 17, 2008 at 9:30 PM, Brian Granger <[EMAIL PROTECTED]> wrote: > > Please correct any new errors I have introduced. > Thanks Brian, I think that's a fair representation. Minor typo "course grained" -> "coarse-grained" -- Nathan Bell [EMAIL PROTECTED] http://graphics.cs.uiuc.edu/~wnbe

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Brian Granger
>> Cython is a different approach from SWIG (see >> http://wiki.cython.org/WrappingCorCpp; in particular SWIG uses more layers >> of indirection). >> > > >From the link: > "[SWIG] Can wrap almost any C and C++ code, including templates etc. > Disadvantage is that it produces a C file, this compiles

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Robert Kern
On Sat, May 17, 2008 at 8:13 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > On Sat, May 17, 2008 at 7:48 PM, Robert Kern <[EMAIL PROTECTED]> wrote: >> For the purposes to which SWIG was applied in that case, the findings >> are accurate. > > IMO it's deliberately misleading. The following three laye

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Nathan Bell
On Sat, May 17, 2008 at 7:48 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > For the purposes to which SWIG was applied in that case, the findings > are accurate. IMO it's deliberately misleading. The following three layers are spurious and have no analog on the Cython stack: Python code to provi

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Robert Kern
On Sat, May 17, 2008 at 7:39 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > More disingenuous FUD here: http://www.sagemath.org/doc/html/prog/node36.html For the purposes to which SWIG was applied in that case, the findings are accurate. The wording is overly general, though; it doesn't talk about

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Nathan Bell
On Sat, May 17, 2008 at 6:42 PM, Dag Sverre Seljebotn <[EMAIL PROTECTED]> wrote: > > Cython is a different approach from SWIG (see > http://wiki.cython.org/WrappingCorCpp; in particular SWIG uses more layers > of indirection). > >From the link: "[SWIG] Can wrap almost any C and C++ code, including

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Nathan Bell
On Sat, May 17, 2008 at 5:55 PM, Jose Martin <[EMAIL PROTECTED]> wrote: > > Hi, I'd like to access a C function from python, and the function takes > input/output arrays. I'd probably use SWIG to do the interface to the C code. > I found 2 options: > -NumPtr module, to access Numeric arrays as po

Re: [Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Dag Sverre Seljebotn
Jose Martin wrote: > > Hi, I'd like to access a C function from python, and the function takes > input/output arrays. I'd probably use SWIG to do the interface to the C > code. I found 2 options: > -NumPtr module, to access Numeric arrays as pointers > http://www.penzilla.net/tutorials/python/numpt

[Numpy-discussion] NumPtr vs NumPy.i to access C

2008-05-17 Thread Jose Martin
Hi, I'd like to access a C function from python, and the function takes input/output arrays. I'd probably use SWIG to do the interface to the C code. I found 2 options: -NumPtr module, to access Numeric arrays as pointers http://www.penzilla.net/tutorials/python/numptr/ - numpy.i, a SWIG interfa