[Patches] [ python-Patches-1103046 ] Boxing up PyDECREF correctly

SourceForge.net noreply at sourceforge.net
Sun Jan 16 02:01:34 CET 2005


Patches item #1103046, was opened at 2005-01-15 14:34
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1103046&group_id=5470

Category: Core (C code)
Group: Python 2.4
Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: Norbert Nemec (nnemec)
Assigned to: Nobody/Anonymous (nobody)
Summary: Boxing up PyDECREF correctly

Initial Comment:
The patch below solves problem in cases like: 
 
if(something) 
    PyDECREF(xxx) 
else 
    dosomethingelse(); 
 
(Patch against Python 2.4) 

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

>Comment By: Tim Peters (tim_one)
Date: 2005-01-15 20:01

Message:
Logged In: YES 
user_id=31435

I wanted to hear what "the problem" was first <wink>.  If, 
e.g., it's some overly helpful compiler complaining about a 
non-existing (in reality) ambiguity about if/else pairing, then 
sticking the "if" part in a block (delimit it with curly braces) 
should shut it up.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-01-15 19:57

Message:
Logged In: YES 
user_id=80475

Sorry, I concur with Tim.

The "problem" has not not proven to be a real world issue in
the many years that Python has been in the wild.

For some compilers, there is a cost to the "solution". 

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

Comment By: Tim Peters (tim_one)
Date: 2005-01-15 19:34

Message:
Logged In: YES 
user_id=31435

What problem?  It's intended that you put a semicolon 
following Py_DECREF() invocations, and if you do I don't see 
any problem here.

The "do ... while(0)" trick isn't optimized away by all 
compilers, so it's not without cost.  Because Py_DECREF 
appears a *lot* in the source code, I don't want its 
expansion to introduce needless overheads.

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

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


More information about the Patches mailing list