[Patches] [ python-Patches-660559 ] Use METH_O and METH_NOARGS where possible

noreply@sourceforge.net noreply@sourceforge.net
Wed, 01 Jan 2003 17:52:34 -0800


Patches item #660559, was opened at 2002-12-31 18:19
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=660559&group_id=5470

Category: Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Walter Dörwald (doerwalter)
Summary: Use METH_O and METH_NOARGS where possible

Initial Comment:
Speed-up calls and tighten code in operator.c 
arraymodule.c, and cStringIO.c by using METH_O, 
METH_NOARGS and PyArg_UnpackTuple.

Didn't touch other modules that I wasn't familiar with 
or that didn't look like they would benefit from the 
speedup.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2003-01-01 20:52

Message:
Logged In: YES 
user_id=31435

Note that a METH_NOARGS function is still called, at the C 
level, with two arguments.  The second argument is always 
NULL, and sooner or later some platform C is going to blow 
up when that's passed to a function declared to take only 
one argument ("the usual" cast to PyCFunction shuts up the 
compile-time warnings).

It's not your job to fix that everywhere, but new uses of 
METH_NOARGS shouldn't add to this problem.  Declaring a 
second PyObject * argument with a name like "unused" 
or "dummy" would be fine.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=660559&group_id=5470