[issue37131] all(range()...)) is needlessley slow
Terji
report at bugs.python.org
Sun Jun 2 06:25:22 EDT 2019
Terji <Terji78 at yahoo.com> added the comment:
>> Why should ``all()`` special case ``range``? Apart from showing off benchmarks, what's the point?
Mostly to avoid silly mistakes, and the overhead of doing it would be very small, so a very small trade-off.
>> Should ``any()`` also special case it?
No, ``any()``takes at most two iterations to check truthiness in a ``range()``, so that's wouldn't be needed.
>> How about other lazy sequences and computed iterables, such as itertools.count objects, itertools.cycle objects, itertools.repeat objects, etc? How many special cases do we want?
No, I wouldn't propose that. The argument would be that those are iterators/generators while ``range()`` is special-cased built-in sequence with known properties.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37131>
_______________________________________
More information about the Python-bugs-list
mailing list