New submission from Terji <terj...@yahoo.com>:

Checking if a range's items are ll truthy can be done y checking if 0 the range 
contains 0, however currently Python iterates over the range, making the 
operation slower than needed.

    >>> rng = range(1, 1_000_000)
    >>> timeit all(rng)
    19.9 ms ± 599 µs per loop

If the all function could special case range, this could be like made fast like 
this:

    if isinstance(obj, range):
        if 0 in obj:
            return False
        return True

----------
components: Interpreter Core
messages: 344263
nosy: Petersen
priority: normal
severity: normal
status: open
title: all(range()...)) is needlessley slow
type: performance
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37131>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to