Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

Another solution is to use an identity test for the step argument

    _one = 1

    class Random:
        def randrange(start, stop=None, step=_one):
            ...
            if stop is None and step is _one:
                if istart > 0:
                    return self._randbelow(istart)

This has the advantage of keeping the API unchanged while still keeping the 
fast path fast.

----------

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

Reply via email to