Skip to content

Commit

Permalink
Fix Issue python#136: replace xrange with range
Browse files Browse the repository at this point in the history
Python 3 has no xrange.
  • Loading branch information
Anselm Kruis committed Oct 9, 2017
1 parent c04b2c8 commit 1f9f0ba
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Stackless/demo/autoscheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def print_name(name, count):

# Helpers
def runtask(name):
for ii in xrange(1000):
for ii in range(1000):
if ii % 50:
run_atomic(print_name, name, ii)

Expand Down
2 changes: 1 addition & 1 deletion Stackless/demo/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def counter(n, ch):
for i in xrange(n):
for i in range(n):
schedule()
ch.send(n)

Expand Down
4 changes: 2 additions & 2 deletions Stackless/test/schedtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def f1(n):
print "f1 called"
for i in xrange(n):
for i in range(n):
# print "f1", i
if i == 4:
if test_exception:
Expand All @@ -22,7 +22,7 @@ def f1(n):

def f2(n):
print "f2 called"
for i in xrange(n):
for i in range(n):
# print "f2", i
if i % 1000 == 0:
schedule()
Expand Down
10 changes: 5 additions & 5 deletions Stackless/test/taskspeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# speed test
if PY3:
import _thread as thread
xrange = range
range = range
else:
import thread

Expand Down Expand Up @@ -74,7 +74,7 @@ def run():


def f(n, sched):
for i in xrange(0, n, 20):
for i in range(0, n, 20):
sched()
sched()
sched()
Expand Down Expand Up @@ -127,7 +127,7 @@ def tester(func, niter, args, msg, ntasks=10, run=run):


def gf(n):
for i in xrange(0, n, 20):
for i in range(0, n, 20):
yield i
yield i
yield i
Expand Down Expand Up @@ -263,7 +263,7 @@ def chantest(n, nest=0, use_thread=False, bulk=False):
else:
tasklet(channel_sender)(chan, nest, bulk)
if bulk:
for i in xrange(0, n, 20):
for i in range(0, n, 20):
# list(chan)
for i in chan:
pass
Expand All @@ -279,7 +279,7 @@ def xrecv():
chan.receive()
getcurrent().next.run()
schedule()
for i in xrange(0, n, 20):
for i in range(0, n, 20):
recv()
recv()
recv()
Expand Down
2 changes: 1 addition & 1 deletion Stackless/test/temptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def stacksize(tasklet):


def f(n, sched):
for i in xrange(0, n, 20):
for i in range(0, n, 20):
sched()
sched()
sched()
Expand Down
2 changes: 1 addition & 1 deletion Stackless/unittests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def refleak_hunting_find_leaks(self, objects=None):
# compute objects, which are alive, but have to less referrers to
# justify their live.
candidates = []
for i in xrange(len(objects)):
for i in range(len(objects)):
if id(objects[i]) in oids:
continue
if len(gc.get_referrers(objects[i])) <= 1:
Expand Down
2 changes: 1 addition & 1 deletion Stackless/unittests/test_miscell.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_soft():

def runtask():
x = 0
# evoke pickling of an xrange object
# evoke pickling of an range object
dummy = range(10)
for ii in range(1000):
x += 1
Expand Down

0 comments on commit 1f9f0ba

Please sign in to comment.