On Nov 7, 11:00 am, "OKB (not okblacke)"
<brennospamb...@nobrenspambarn.net> wrote:

>         What is the point of the all() function being a builtin if it's
> slower than writing a function to do the check myself?
>

But, you didn't write an all() function.  You wrote a more specialized
allBoolean() function. I think this comparison is more fair to the
builtin all():

>>> def myAll(x):
...     for a in x:
...         if not a: return False
...     return True
...
>>> timeit.timeit('myAll(a in (True, False) for a in x)', 'from __main__ import 
>>> myAll, x', number=10)
14.510986388627998
>>> timeit.timeit('all(a in (True, False) for a in x)', 'from __main__ import 
>>> x', number=10)
12.209779342432576
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to