Stefan Behnel wrote:
Hugo Arts, 08.11.2010 00:53:
[...]
On another note, getting rid of the list comprehension and using a
generator expression will be even faster, since you won't have to
build the list.

I gave this suggestion a try. It is true for me when run in CPython 3.2:
[...]
However, it is no longer true when I run the same thing in Cython:
[...]
Lesson learned:

Sometimes, it can be worth splitting a loop in two, one with a tight filter for the values, and another one to work on the remaining values.

Nice analysis, thank you. However, surely the most important lesson to be learned is:

Don't make assumptions about what is faster, measure it and find out!



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to