[Cython] None checks for variables of builtin types (rev ffeb158969e)

Stefan Behnel stefan_ml at behnel.de
Fri Feb 27 08:17:44 CET 2009


Robert Bradshaw wrote:
> On Feb 26, 2009, at 10:05 PM, Stefan Behnel wrote:
>> this change:
>>[...]
>> does not handle the case that the 'list' might be None.
> 
> Good point. I'm pushing a fix.

Regarding this bit:

	likely(o != Py_None && 0 <= i && i < PyList_GET_SIZE(o))

Does anyone know if gcc handles this as desired? Does this mean that the
whole expression is likely, and does that make each part likely, or would
it be better to wrap each part of the expression in its own likely()?

(BTW, likely() refers to GCC's __builtin_expect() here)


> I'd love for someone to implement a control flow analysis--I started to
> but never had time to finish (or do it right).

I guess the "someone" bit is the main problem here. ;)

The "do it right" can also refer to complexity, BTW. There was a post on
c.l.py a couple of months ago where someone presented some heavy algorithm
(don't remember what it did) and asked for ways to make it faster. I just
went: "ah, I can use Cython for that", but I didn't even manage to compile
it. It contained an impressively long list of "if" statements, just one
after the other (no nesting), and that let the control flow analysis die
from stack exhaustion.

Stefan



More information about the Cython-dev mailing list