Skip to content
Prev Previous commit
Next Next commit
Use range over 0 <= for loops
  • Loading branch information
hexgnu committed Feb 2, 2018
commit 5e59e9cbcc3653d0faa4505bad1a7ed8c3f797f8
18 changes: 9 additions & 9 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ def fast_unique_multiple(list arrays):
dict table = {}
object val, stub = 0

for i from 0 <= i < k:
for i in range(k):
buf = arrays[i]
n = len(buf)
for j from 0 <= j < n:
for j in range(n):
val = buf[j]
if val not in table:
table[val] = stub
Expand All @@ -158,10 +158,10 @@ def fast_unique_multiple_list(list lists):
dict table = {}
object val, stub = 0

for i from 0 <= i < k:
for i in range(k):
buf = lists[i]
n = len(buf)
for j from 0 <= j < n:
for j in range(n):
val = buf[j]
if val not in table:
table[val] = stub
Expand Down Expand Up @@ -200,7 +200,7 @@ def fast_unique_multiple_list_gen(object gen, bint sort=True):

for buf in gen:
n = len(buf)
for j from 0 <= j < n:
for j in range(n):
val = buf[j]
if val not in table:
table[val] = stub
Expand Down Expand Up @@ -830,15 +830,15 @@ def count_level_2d(ndarray[uint8_t, ndim=2, cast=True] mask,
if axis == 0:
counts = np.zeros((max_bin, k), dtype='i8')
with nogil:
for i from 0 <= i < n:
for j from 0 <= j < k:
for i in range(n):
for j in range(n):
counts[labels[i], j] += mask[i, j]

else: # axis == 1
counts = np.zeros((n, max_bin), dtype='i8')
with nogil:
for i from 0 <= i < n:
for j from 0 <= j < k:
for i in range(n):
for j in range(k):
counts[i, labels[j]] += mask[i, j]

return counts
Expand Down