Jared Forsyth, 28.06.2010 17:04: > In the manual, it states that "for i in range(...)" gets automatically > converted to "for i from..." for performance benefits.
Sounds like you didn't read on from the point where it said that. If that's really all it says, please provide a link to the docs, so that we can fix it. > But it doesn't... I've tried > > cdef int a=5 > for i in range(a):pass > > and > > for i in range(10):pass > > and neither are converted. Is the documentation wrong? [it seems like at > least the second one should be optimized] You didn't state which Cython version you are using, so I assume it's 0.12.1, which doesn't automatically optimise these things yet. You have to explicitly tell it that it's safe to restrict 'i' to a C integer in order to let it break the normal Python semantics of your code. Cython 0.13 will recognise the second case, though, and I think even the first one. Then, the C compiler should be able to drop the above loops as dead code, as expected. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
