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

noreply@sourceforge.net noreply@sourceforge.net
Thu, 02 Jan 2003 23:12:20 -0800


Patches item #660559, was opened at 2002-12-31 15: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: Martin v. Löwis (loewis)
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: Brett Cannon (bcannon)
Date: 2003-01-02 23:12

Message:
Logged In: YES 
user_id=357491

So I just finished reading the diff and it all looks good to
me (I think).  I basically just read through the diff and
when I saw  the original I tried to guess how Raymond
changed it and see what he did, in fact, change it to in the
end.  All turned out the way I expected it.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-01 18:27

Message:
Logged In: YES 
user_id=80475

Fixed.  Revised patch attached.

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

Comment By: Tim Peters (tim_one)
Date: 2003-01-01 17: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