[Python-Dev] METH_NOARGS calling convention

Martin von Loewis loewis@informatik.hu-berlin.de
Fri, 1 Jun 2001 19:07:52 +0200 (MEST)

The patch


introduces two new calling conventions, METH_O and METH_NOARGS. The
rationale for METH_O has been discussed already; the rationale for
METH_NOARGS is that it allows a convient simplification (plus a
marginal speed-up) of functions which do either PyArg_NoArgs(args) or
PyArg_ParseTuple(args, ":function_name").

Now, one open issue is whether the METH_NOARGS functions should have
a signature of

  PyObject * (*unaryfunc)(PyObject *);

or of 

  PyObject *(*PyCFunction)(PyObject *, PyObject *);

which then would be called with a NULL second argument; the first
argument would be self in either case.

IMO, the advantage of passing the NULL argument is that NOARGS methods
don't need to be cast into PyCFunction in the method table; the
advantage of the second approach is that it is clearer in the function

Any opinions which signature to use?