[Cython] getting rid of C' stlib strcmp() in generated sources

Stefan Behnel stefan_ml at behnel.de
Sat Mar 7 15:21:17 CET 2009


Robert Bradshaw wrote:
> On Mar 6, 2009, at 11:06 PM, Stefan Behnel wrote:
>> Lisandro Dalcin wrote:
>>> Cython uses it in just a few
>>> places, and mainly for work around some deficiencies in the Python
>>> C-API, then I what to remove this dependency from Cython generated
>>> code.
>> I have no idea where that's currently used and if those places are  
>> in any
>> way performance critical, so I can't comment without looking into  
>> this. I might even have added a couple of those myself.
> 
> Most places it's used to (1) verify types on importing, (2) verify C  
> api matches, and (3) to verify un-exported types in classmethod and   
> cpdef functions, and (4) in keyword parsing code. The first two don't  
> need to be fast, the third should be optimized anyways (at least the  
> cpdef methods) so I'm going to do that after Lisandro's patch, and  
> the last I'm not sure about.

4) isn't performance critical either. The generic keyword parsing utility
function is no longer called for keyword-only arguments or normally
declared keyword arguments, as long as you do not use **kwargs. And if it's
needed, I would expect the PyDict_Next() loop to dominate any string
comparisons. And in the extremely likely case that we are dealing with
interned strings, we skip the content comparison all together.

I guess I'm +0 on this then.

Stefan



More information about the Cython-dev mailing list