Re: wrapping C functions in python

2008-04-10 Thread Robert Kern
Paul Anton Letnes wrote: > Brian and Diez: > > First of all, thanks for the advice. > > Brian: > > I have installed NumPy and SciPy, but I can't seem to find a wavelet > transform there. Well, you will definitely want to use numpy arrays instead of lists or the standard library's arrays to c

Re: wrapping C functions in python

2008-04-10 Thread Ivan Illarionov
On Apr 10, 9:57 am, Paul Anton Letnes <[EMAIL PROTECTED]> wrote: [...] > , but as I mentioned, it seems to be a bit complicated to wrap heavy > data structures like arrays. Hello, I suggest that you might take a look at how other people solved the same problems. The great example is path.c insi

Re: wrapping C functions in python

2008-04-10 Thread Jaap Spies
Paul Anton Letnes wrote: > Hi, and thanks. > > > However, being a newbie, I now have to ask: What is SWIG? I have heard > the name before, but haven't understood what it is, why I need it, or > similar. Could you please supply some hints? > [...] >>> >>> I am a "scientific" user of Python, and

Re: wrapping C functions in python

2008-04-10 Thread Diez B. Roggisch
Paul Anton Letnes schrieb: > Brian and Diez: > > First of all, thanks for the advice. > > Brian: > > I have installed NumPy and SciPy, but I can't seem to find a wavelet > transform there. > > The main point of this was more to learn C wrapping than to actually get > a calculation done. I wil

Re: wrapping C functions in python

2008-04-09 Thread Paul Anton Letnes
Brian and Diez: First of all, thanks for the advice. Brian: I have installed NumPy and SciPy, but I can't seem to find a wavelet transform there. The main point of this was more to learn C wrapping than to actually get a calculation done. I will probably be starting a PhD soon, doing real

Re: wrapping C functions in python

2008-04-09 Thread Brian Cole
SWIG is a program that automatically generates code to interface Python (and many other languages) with C/C++. If you plan to create lasting software libraries to be accessed from Python and C it is quite a robust way to do so. Essentially, you feed it header files, compile your code and the code

Re: wrapping C functions in python

2008-04-09 Thread Paul Anton Letnes
Hi, and thanks. However, being a newbie, I now have to ask: What is SWIG? I have heard the name before, but haven't understood what it is, why I need it, or similar. Could you please supply some hints? -Paul Den 9. april. 2008 kl. 22.22 skrev Brian Cole: > We use the following SWIG (www.

Re: wrapping C functions in python

2008-04-09 Thread Diez B. Roggisch
>> I am a "scientific" user of Python, and hence have to write some performance >> critical algorithms. Right now, I am learning Python, so this is a "newbie" >> question. >> >> I would like to wrap some heavy C functions inside Python, specifically a >> wavelet transform. I am beginning to become

Re: wrapping C functions in python

2008-04-09 Thread Brian Cole
We use the following SWIG (www.swig.org) typemap to perform such operations: %typemap(in) (int argc, char **argv) { if (!PySequence_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a sequence"); return NULL; } $1 = PySequence_Length($input); $2 = (char**)alloca($1*sizeof

wrapping C functions in python

2008-04-09 Thread Paul Anton Letnes
Hello etc. I am a "scientific" user of Python, and hence have to write some performance critical algorithms. Right now, I am learning Python, so this is a "newbie" question. I would like to wrap some heavy C functions inside Python, specifically a wavelet transform. I am beginning to bec

Re: Wrapping C functions in Pyrex and distutils problem

2005-11-09 Thread Diez B. Roggisch
Use additional_objects: LINKBASE = "link-4.1b" setup( name = "LinkWrapper", ext_modules = [ Extension("link", ["link.pyx"], include_dirs = ["%s/include" % LINKBASE], extra_objects = glob.glob("%s/obj/*" % LINKBASE), ) ], cmdclass

Wrapping C functions in Pyrex and distutils problem

2005-11-09 Thread TPJ
I'm trying to get a wrapper for my C code in order to be able to use it as a module in Python. I'm doing it as follows: C code (file_c.c): --- #include void hello( int size ) { printf("Hello! %d\n", size); } --- Pyrex code (file.pyx): ---

Re: Wrapping c functions

2005-05-01 Thread David M. Cooke
Andrew Dalke <[EMAIL PROTECTED]> writes: > Glenn Pierce wrote: >> if (!PyArg_ParseTuple(args, "isi", &format, filename, &flags)) >> return NULL; > > Shouldn't that be &filename ? See > http://docs.python.org/ext/parseTuple.html > for examples. > > >> dib = FreeImage_

Re: Wrapping c functions

2005-05-01 Thread Andrew Dalke
Glenn Pierce wrote: > if (!PyArg_ParseTuple(args, "isi", &format, filename, &flags)) > return NULL; Shouldn't that be &filename ? See http://docs.python.org/ext/parseTuple.html for examples. > dib = FreeImage_Load(format, filename, flags); > Also I have little Ide

Wrapping c functions

2005-05-01 Thread Glenn Pierce
Hi I have been trying to wrap a c library called FreeImage for python and am having trouble with a couple of functions. One function is FreeImage_Load which takes parameters (enum, const char*, int) I have wrapped the function with the following code static PyObject * freeimage_load(PyObject *sel