[Cython] Assignments in cdefs
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Sun Jul 20 20:29:33 CEST 2008
Dag Sverre Seljebotn wrote:
> Stefan Behnel wrote:
>> What about code like this:
>>
>> def test(a):
>> cdef int c
>> if a:
>> c = 1
>> if not a:
>> c = 2
>>
>
> As for the example, it is a "best-effort" thing. If no assignments are
> flagged as first, then the optimization just doesn't happen, which is
> the likely outcome of your example. However, if you come up with an
> algorithm to check this, then in this case you can flag them both as first.
In fact, in this example there is no first assignment, as you could
overload __not__ and have True in both cases :-) In general such
sophisticated control only works for c-typed branch tests which makes me
doubt the value of it...?
But it doesn't look horrendously difficult to write code tackling it
either...but that's another GSoC :-)
--
Dag Sverre
More information about the Cython-dev
mailing list