Commit c9a5a0e1 authored by Georg Brandl's avatar Georg Brandl

#6814: remove traces of xrange().

parent a4c05a26
...@@ -98,17 +98,17 @@ def test(): ...@@ -98,17 +98,17 @@ def test():
t = time.time() t = time.time()
A = list(map(pow3, range(N))) A = list(map(pow3, range(N)))
print('\tmap(pow3, xrange(%d)):\n\t\t%s seconds' % \ print('\tmap(pow3, range(%d)):\n\t\t%s seconds' % \
(N, time.time() - t)) (N, time.time() - t))
t = time.time() t = time.time()
B = pool.map(pow3, range(N)) B = pool.map(pow3, range(N))
print('\tpool.map(pow3, xrange(%d)):\n\t\t%s seconds' % \ print('\tpool.map(pow3, range(%d)):\n\t\t%s seconds' % \
(N, time.time() - t)) (N, time.time() - t))
t = time.time() t = time.time()
C = list(pool.imap(pow3, range(N), chunksize=N//8)) C = list(pool.imap(pow3, range(N), chunksize=N//8))
print('\tlist(pool.imap(pow3, xrange(%d), chunksize=%d)):\n\t\t%s' \ print('\tlist(pool.imap(pow3, range(%d), chunksize=%d)):\n\t\t%s' \
' seconds' % (N, N//8, time.time() - t)) ' seconds' % (N, N//8, time.time() - t))
assert A == B == C, (len(A), len(B), len(C)) assert A == B == C, (len(A), len(B), len(C))
......
...@@ -396,7 +396,7 @@ by file descriptors. ...@@ -396,7 +396,7 @@ by file descriptors.
Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive), Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive),
ignoring errors. Availability: Unix, Windows. Equivalent to:: ignoring errors. Availability: Unix, Windows. Equivalent to::
for fd in xrange(fd_low, fd_high): for fd in range(fd_low, fd_high):
try: try:
os.close(fd) os.close(fd)
except OSError: except OSError:
......
...@@ -606,7 +606,7 @@ from time import clock as now ...@@ -606,7 +606,7 @@ from time import clock as now
def fill(n): def fill(n):
from random import random from random import random
return [random() for i in xrange(n)] return [random() for i in range(n)]
def mycmp(x, y): def mycmp(x, y):
global ncmp global ncmp
......
...@@ -431,7 +431,7 @@ PyTypeObject PyRangeIter_Type = { ...@@ -431,7 +431,7 @@ PyTypeObject PyRangeIter_Type = {
rangeiter_new, /* tp_new */ rangeiter_new, /* tp_new */
}; };
/* Return number of items in range/xrange (lo, hi, step). step > 0 /* Return number of items in range (lo, hi, step). step > 0
* required. Return a value < 0 if & only if the true value is too * required. Return a value < 0 if & only if the true value is too
* large to fit in a signed long. * large to fit in a signed long.
*/ */
......
...@@ -260,10 +260,7 @@ class IntegerCounting(Test): ...@@ -260,10 +260,7 @@ class IntegerCounting(Test):
# Run test rounds # Run test rounds
# #
# NOTE: Use xrange() for all test loops unless you want to face for i in range(self.rounds):
# a 20MB process !
#
for i in xrange(self.rounds):
# Repeat the operations per round to raise the run-time # Repeat the operations per round to raise the run-time
# per operation significantly above the noise level of the # per operation significantly above the noise level of the
...@@ -305,7 +302,7 @@ class IntegerCounting(Test): ...@@ -305,7 +302,7 @@ class IntegerCounting(Test):
a = 1 a = 1
# Run test rounds (without actually doing any operation) # Run test rounds (without actually doing any operation)
for i in xrange(self.rounds): for i in range(self.rounds):
# Skip the actual execution of the operations, since we # Skip the actual execution of the operations, since we
# only want to measure the test's administration overhead. # only want to measure the test's administration overhead.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment