One of the pycon2011 talks shared this any()
function trick; the explanation was that the loop is in C.
Could someone explain more about it? What is the trick behind it and is there any other use cases?
>>> import itertools, hashlib, time
>>> _md5 = hashlib.md5()
>>> def run():
... for i in itertools.repeat('foo', 10000000):
... _md5.update(i)
...
>>> a = time.time(); run(); time.time() -a
3.9815599918365479
>>> _md5 = hashlib.md5()
>>> def run():
... any(itertools.imap(_md5.update, itertools.repeat('foo', 10000000)))
...
>>> a = time.time(); run(); time.time() -a
2.1475138664245605
>>>