[Cython] PATCH: removing strcmp() in favor of custom impl or other fixes

Robert Bradshaw robertwb at math.washington.edu
Sun Mar 8 00:40:09 CET 2009


On Mar 7, 2009, at 12:39 PM, Stefan Behnel wrote:

> Lisandro Dalcin wrote:
>> On Sat, Mar 7, 2009 at 4:47 PM, Stefan Behnel  
>> <stefan_ml at behnel.de> wrote:
>>> Note that I already used (almost) the same optimisation in the  
>>> code, which
>>> now becomes superfluous. Although I expect it to be a lot faster  
>>> to check
>>> the length inside the loop before calling into the Python's C- 
>>> API, these
>>> checks should be rare enough to just make that
>>>
>>>        if (_PyString_Eq(**name, key)) ...
>>
>> OK. I did not give a full review of that part of the code. So then
>> this _PyString_Eq() call will unlikely be ever made, right?
>
> Yes. The most common cases are handled directly inside the  
> function's own
> init code, so it's unlikely already that this function will be  
> called in a
> time critical context. Then, most keyword names are inlined, so the
> fast-path at the beginning of the loop body will hit. If it does  
> not, it's
> either the rare case that a non-inlined keyword name was passed, or  
> one of
> the possible error cases. None of these it performance critical.

Note I removed a strcmp() at http://hg.cython.org/cython-devel/rev/ 
cd51476651c6 which will make one chunk from your patch unnecessary  
(just a heads up when you merge).

- Robert



More information about the Cython-dev mailing list