[Patches] [ python-Patches-661440 ] Refactor and streamline PyCFunction_Call

SourceForge.net noreply@sourceforge.net
Fri, 03 Jan 2003 09:06:08 -0800


Patches item #661440, was opened at 2003-01-03 03:06
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=661440&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Martin v. Löwis (loewis)
Summary: Refactor and streamline PyCFunction_Call

Initial Comment:
Refactor PyCFunction_Call with an eye towards 
clarity and speed while leaving the semantics 
unchanged.  

It is now obvious which combinations of flags are 
allowed; the new structure makes it easier to add new 
flags and flag combinations; and every path runs 
faster (by having fewer jumps, filling variables only 
when and where needed, and by merging a test into 
the switch logic).

* Incorporated the keyword flag test into switch/case.
* Deferred initialization of "size" until when and where 
needed.
* Inverted error tests so that the common case has 
no jumps.



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

>Comment By: Jeremy Hylton (jhylton)
Date: 2003-01-03 17:06

Message:
Logged In: YES 
user_id=31392

Do you have any measurements of the speedup?


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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-03 11:22

Message:
Logged In: YES 
user_id=80475

For me, the clarity comes from all allowable flag 
combinations being shown in the switch/case.

The duplication of the test for empty dictionaries and the 
computation of size are done for speed (only being done 
when and where needed).  The duplication is warranted 
only because the function is on the critical path for just 
about everything in Python and here speed really matters.

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

Comment By: Martin v. Löwis (loewis)
Date: 2003-01-03 10:40

Message:
Logged In: YES 
user_id=21627

I'm uncertain why this makes the function clearer; it
appears to make it merely different, as it duplicates the
test for empty dictionaries, and the computation of the size.



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

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-01-03 10:19

Message:
Logged In: YES 
user_id=80475

Should've been assigned to Martin who wrote some of the 
existing code for that function.

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

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