DECREFing and PyArray functions in C Extensions
Christian Tismer
tismer at tismer.com
Mon May 29 08:30:43 EDT 2000
"Louis M. Pecora" wrote:
>
> In article <ya0hfbig5g7.fsf at trymheim.ifi.uio.no>, Roger Hansen
> <rogerha at ifi.uio.no> wrote:
>
> > static PyObject *
> > foo(PyObject *self, PyObject* args)
> > {
> > PyArrayObject *array;
> > double* a; /* C ptr to the NumPy array data field */
> >
> > if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) {
> > return NULL; /* Error indicator */
> > }
> [cut]
> >
> > Py_INCREF(Py_None); return Py_None;
> > }
> >
> > where f is some function. I don't need to DECREF array in this
> > example since PyArg_ParseTuple does not increase the reference count,
> > right?
>
> That looks right to me, but what is this:
>
> Py_INCREF(Py_None); return Py_None;
>
> What's going on there with Py_None?
The function is supposed to return no value.
Returning no value in Python means to INCREF and return Py_None.
ciao - chris
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
where do you want to jump today? http://www.stackless.com
More information about the Python-list
mailing list