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.

classification
Title: Use METH_O and METH_NOARGS where possible
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: brett.cannon, loewis, rhettinger, tim.peters
Priority: normal Keywords: patch

Created on 2002-12-31 23:19 by rhettinger, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unpack.diff rhettinger, 2002-12-31 23:20
arg.diff rhettinger, 2003-01-02 02:27 Revised patch with dummy arguments
Messages (6)
msg42176 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-12-31 23:19
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.
msg42177 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-01-02 01:52
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.
msg42178 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-02 02:27
Logged In: YES 
user_id=80475

Fixed.  Revised patch attached.
msg42179 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-01-03 07:12
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.
msg42180 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-03 08:13
Logged In: YES 
user_id=21627

I agree that the patch looks fine; Raymond, please apply it.
msg42181 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-01-03 08:28
Logged In: YES 
user_id=80475

Checked in as: arraymodule.c 2.80, cStringIO.c 2.39,and 
operator.c 2.26.

Thank you Tim, Brett, and Martin for the quality control.
History
Date User Action Args
2022-04-10 16:06:04adminsetgithub: 37675
2002-12-31 23:19:29rhettingercreate