PyInline Released: Put C source code directly "inline" with your Python!

Alexey Goldin Alexey.Goldin at jpl.nasa.gov
Fri Aug 31 20:41:35 CEST 2001


"Thomas Heller" <thomas.heller at ion-tof.com> writes:

> > The question is, what I am doing wrong here (or is it allowed at all)?
> >
> > ############ simple test code ##################
> > from PyInline import C
> >
> > x = C.Builder(code="""
> > PyObject* test_pyobj(PyObject *self, PyObject *args) {
> >   int t;
> >   if (!PyArg_ParseTuple(args, "i", &t))
> >         return NULL;
> >   return Py_BuildValue("i", t*2) ;
> > }
> >
> > """)
> PyInline probably tries to wrap your function (which is not
> needed because it is already wrapped). You should examine
> the generated source-code.

Yes, you are right. But I explicitly tried if I can pass PyObject to handle 
something arrays, PyGtkObject, etc...

Well, it is pretty cool anyway and works amazinly well for 0.02 version.

> 
> From the docs (I haven't tried it) it seems you should write:
> x = C.Builder(code="""
> int times_two(int t) {
>     return t*2;
> }
> """)
> 
> Thomas



More information about the Python-list mailing list