[Cython] About IndexNode and unicode[index]

Stefan Behnel stefan_ml at behnel.de
Sat Mar 2 11:52:34 CET 2013


Robert Bradshaw, 01.03.2013 09:25:
> On Thu, Feb 28, 2013 at 10:54 PM, Zaur Shibzukhov wrote:
>>>>> I think you could even pass in two flags, one for wraparound and one for
>>>>> boundscheck, and then just evaluate them appropriately in the existing "if"
>>>>> tests above. That should allow both features to be supported independently
>>>>> in a fast way.
>>>>>
>>>> Intresting, could C compilers in optimization mode to eliminate unused
>>>> evaluation path in nested if statements with constant conditional
>>>> expressions?
>>>
>>> They'd be worthless if they didn't do that. (Even Cython does it, BTW.)
>>>
>> Then it can simplify writing utility code in order to support
>> different optimization flags in other cases too.
> 
> The one thing you don't have much control over is whether the C
> compiler will actually inline the function (CYTHON_INLINE is just a
> hint). In particular, it may decide the function is too large to
> inline before realizing how small it would become given the constant
> arguments. I'm actually not sure how much of a problem this is in
> practice...

I tried it out for the Get/Set/DelItemInt() utility functions and took a
look at the generated assembly (gcc -O3). It does look as expected and
sometimes also better than what we currently generate. So I think it's
worth it.

https://github.com/scoder/cython/commit/cc4f7daec3b1f19b5acaed7766e2b6f86902ad94

I'd be happy if someone else could give this change a review to make sure I
got all conditions right.

Stefan



More information about the cython-devel mailing list