This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nnorwitz
Recipients
Date 2005-01-23.18:32:06
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This patch adds a new method type (flags) METH_ARGS
(yeah, the name could be better) that is used in
PyMethodDef.  METH_ARGS means the min and max # of
arguments are specified in the PyMethodDef by adding 2
new fields.  This information can be used in ceval to
call the method.  No tuple packing/unpacking is
required since the C stack is used.

The original patch only modifies Python/bltinmodule.c.
 If the approach is desirable, Objects/*.c should be
modified and so should code in Modules/ (probably).

The benefits are:
 * faster function calls
 * simplify function call machinery by removing
METH_NOARGS, METH_O, and possibly METH_VARARGS
 * more introspection info for C functions (ie, min/max
arg count)

The primary drawback is:
 * the defn of the MethodDef (# args) is separate from
the function defn
 * potentially more error prone to write C methods???

I've measured between 13-22% speed improvement when
doing simple tests like:

  ./python ./Lib/timeit.py -v 'pow(3, 5)'

I think the difference tends to be fairly constant at
about .3 usec per loop.

I'm not sure of the effect on memory usage.  I wouldn't
expect it to be much in either direction.

Note:  This patch does not make the min/max arg count
available to Python code.  If this patch is accepted,
that seems like it should also be done.

It's possible that METH_VARARGS may not be able to go away.
History
Date User Action Args
2007-08-23 15:41:26adminlinkissue1107887 messages
2007-08-23 15:41:26admincreate