On Thu, Jun 20, 2013 at 2:14 AM, <russ.po...@gmail.com> wrote: > And the following, although the same thing really as all(xrange(10**9)), is > not as instant and will take even longer than the above. > >>>> all(map(lambda x: bool(x), xrange(10**9))) > > However if all by some chance (I don't know how this stuff works underneath) > has a key parameter then we could do something like. > >>>> all(xrange(10**9), key=lambda x: bool(x)) > > Which would return False instantly (ideally).
All you need is the iterator version of map(). In Python 3, that's the normal map(); in Python 2, use this: >>> from itertools import imap >>> all(imap(lambda x: bool(x), xrange(10**9))) False It's roughly instant, like you would expect. ChrisA -- http://mail.python.org/mailman/listinfo/python-list