]> granicus.if.org Git - python/commit
Introducing randrange([start,] stop [,step]) -- same as
authorGuido van Rossum <guido@python.org>
Fri, 31 Jul 1998 13:39:44 +0000 (13:39 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 31 Jul 1998 13:39:44 +0000 (13:39 +0000)
commit187f154243eb43b2d81f9b253458a16880e1b0bb
treeadcd2fcabffd96c3d7942469c1a3ff8497b42b52
parent490ec9c8773fd117cb724522b94eaac8e03932ef
Introducing randrange([start,] stop [,step]) -- same as
choice(range(start, stop, step)) but faster.  This addresses the
problem that randint() was accidentally defined as taking an inclusive
range (how unpythonic).

The code is longish because Tim Peters insisted that it reject
non-integral arguments while I insisted that it be not much slower
than randint(); the compromise satisfies both but is somewhat
convoluted.

Also changed randint() to be implemented through randrange().  This is
a semantic change because old randint() didn't test its arguments for
validity.  (It also makes randrange() win any contest with randint()
:-)
Lib/whrandom.py