Py_INCREF / DECREF not needed in simple C functions?

Owen F. Ransen ransen_spam_me_not at nemo.it
Fri Mar 2 00:19:27 EST 2001


On Thu, 1 Mar 2001 16:17:04 +0100, "Alex Martelli" <aleaxit at yahoo.com>
wrote:

>Actually, you _should_ incref None if you want to
>return it -- or, use
>    return Py_BuildValue("");
>to return None, and then you can keep not worrying:-).
>Alex

Thanks for the tip, so I should do this:

static PyObject* Py_ReallyWildFunc (PyObject *self, PyObject *args)
{
    double x,y,z ;
    if (!PyArg_ParseTuple(args, "ddd",&x,&y,&z)) {
        return (NULL) ;
    }

    ...do some really wild stuff with x,y,z...

    Py_INCREF (Py_None) ;
    return (Py_None) ;
}

?


--
Owen F. Ransen
http://www.ransen.com/
Home of Gliftic & Repligator Image Generators



More information about the Python-list mailing list