Re:PyCon 2011: How Dropbox Did It and How Python Helped
by jedsmith on Monday March 14, 2011 @10:31AM
(#2322593)
The iterator is consumed in C using any(), instead of the Python bytecode being executed to perform the loop. I don't know if it'd work for "any Python function," but I'd definitely look at it for long-running iterators.
From my understanding, the any() version is faster is primarily because it avoids looking up .update() method each iteration. The usual Python way of optimizing such cases is: