Author rhettinger
Recipients rhettinger, serhiy.storchaka, terry.reedy, tim.peters, veky
Date 2020-12-25.22:38:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608935931.66.0.906835422809.issue42222@roundup.psfhosted.org>
In-reply-to
Content
There is another randrange() oddity.  If stop is None, the step argument is ignored:

    >>> randrange(100, stop=None, step=10)
    4

If we want to fully harmonize with range(), then randrange() should only accept positional arguments and should not allow None for the stop argument.  That would leave the unoptimized implementation equivalent to:

    def randrange(self, /, *args):
        return self.choice(range(*args))

The actual implementation can retain its fast paths and have a nicer looking signature perhaps using __text_signature__.
History
Date User Action Args
2020-12-25 22:38:51rhettingersetrecipients: + rhettinger, tim.peters, terry.reedy, serhiy.storchaka, veky
2020-12-25 22:38:51rhettingersetmessageid: <1608935931.66.0.906835422809.issue42222@roundup.psfhosted.org>
2020-12-25 22:38:51rhettingerlinkissue42222 messages
2020-12-25 22:38:51rhettingercreate