Hi,
should we let Cython know certain stdlib modules and consider their import
as something that won't change meaning at runtime?
This is mainly driven by loop optimisations. Imagine
from itertools import izip
always referred to the same thing. Then Cython could translate
for a,b in izip(seq1, seq2):
...
into (the equivalent of)
while True:
try:
temp_a = seq1.next()
temp_b = seq2.next()
except StopIteration:
break
a,b = temp_a, temp_b
...
instead of letting izip create a new iterator and tons of tuples along the
way, plus the obvious optimisations for constant sequences, lists, dicts,
etc. (Note that doing this for Py2's builtin zip() would not be correct as
the sequences are allowed to change during iteration in that case).
http://wiki.cython.org/enhancements/forin
Or think of the math module and its constants and functions. We could use
specialised C functions instead if we know the types that we are applying
them to. That way, users wouldn't have to care about two sets of functions
in Python's math module and C's math.h.
Comments?
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev