Skip to content

Commit f1006e6

Browse files
committed
Remove usage of the six module
1 parent 7dbb76d commit f1006e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+271
-363
lines changed

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
Version 1.0.1
55
-------------
66

7+
* Drop usage of the six module since Python 2 is no longer supported.
78
* Update dependencies:
89

910
* Django: 3.0 => 3.0.3

pyperformance/benchmarks/bm_chameleon.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import functools
22

3-
import six
43
import pyperf
54

65
from chameleon import PageTemplate
@@ -12,11 +11,11 @@
1211
<tr tal:repeat="row python: options['table']">
1312
<td tal:repeat="c python: row.values()">
1413
<span tal:define="d python: c + 1"
15-
tal:attributes="class python: 'column-' + %s(d)"
14+
tal:attributes="class python: 'column-' + str(d)"
1615
tal:content="python: d" />
1716
</td>
1817
</tr>
19-
</table>""" % six.text_type.__name__
18+
</table>"""
2019

2120

2221
def main():

pyperformance/benchmarks/bm_chaos.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import random
1010

1111
import pyperf
12-
import six
13-
from six.moves import xrange
1412

1513

1614
DEFAULT_THICKNESS = 0.25
@@ -136,11 +134,7 @@ def write_ppm(im, filename):
136134
w = len(im)
137135
h = len(im[0])
138136

139-
if six.PY3:
140-
fp = open(filename, "w", encoding="latin1", newline='')
141-
else:
142-
fp = open(filename, "wb")
143-
with fp:
137+
with open(filename, "w", encoding="latin1", newline='') as fp:
144138
fp.write(magic)
145139
fp.write('%i %i\n%i\n' % (w, h, maxval))
146140
for j in range(h):
@@ -227,7 +221,7 @@ def create_image_chaos(self, w, h, iterations, filename, rng_seed):
227221
im = [[1] * h for i in range(w)]
228222
point = GVector((self.maxx + self.minx) / 2,
229223
(self.maxy + self.miny) / 2, 0)
230-
for _ in xrange(iterations):
224+
for _ in range(iterations):
231225
point = self.transform_point(point)
232226
x = (point.x - self.minx) / self.width * w
233227
y = (point.y - self.miny) / self.height * h

pyperformance/benchmarks/bm_crypto_pyaes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
import pyperf
9-
from six.moves import xrange
109

1110
import pyaes
1211

@@ -18,7 +17,7 @@
1817

1918

2019
def bench_pyaes(loops):
21-
range_it = xrange(loops)
20+
range_it = range(loops)
2221
t0 = pyperf.perf_counter()
2322

2423
for loops in range_it:

pyperformance/benchmarks/bm_django_template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
This will have Django generate a 150x150-cell HTML table.
44
"""
55

6-
from six.moves import xrange
76
import pyperf
87

98
import django.conf
@@ -21,7 +20,7 @@ def bench_django_template(runner, size):
2120
{% endfor %}
2221
</table>
2322
""")
24-
table = [xrange(size) for _ in xrange(size)]
23+
table = [range(size) for _ in range(size)]
2524
context = Context({"table": table})
2625

2726
runner.bench_func('django_template', template.render, context)

pyperformance/benchmarks/bm_fannkuch.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66
"""
77

88
import pyperf
9-
from six.moves import xrange
109

1110

1211
DEFAULT_ARG = 9
1312

1413

1514
def fannkuch(n):
16-
count = list(xrange(1, n + 1))
15+
count = list(range(1, n + 1))
1716
max_flips = 0
1817
m = n - 1
1918
r = n
2019
check = 0
21-
perm1 = list(xrange(n))
22-
perm = list(xrange(n))
20+
perm1 = list(range(n))
21+
perm = list(range(n))
2322
perm1_ins = perm1.insert
2423
perm1_pop = perm1.pop
2524

pyperformance/benchmarks/bm_float.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Artificial, floating point-heavy benchmark originally used by Factor.
33
"""
4-
from six.moves import xrange
54
import pyperf
65

76
from math import sin, cos, sqrt
@@ -46,7 +45,7 @@ def maximize(points):
4645

4746
def benchmark(n):
4847
points = [None] * n
49-
for i in xrange(n):
48+
for i in range(n):
5049
points[i] = Point(i)
5150
for p in points:
5251
p.normalize()

pyperformance/benchmarks/bm_genshi.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
import pyperf
6-
from six.moves import xrange
76

87
from genshi.template import MarkupTemplate, NewTextTemplate
98

@@ -29,7 +28,7 @@ def bench_genshi(loops, tmpl_cls, tmpl_str):
2928
tmpl = tmpl_cls(tmpl_str)
3029
table = [dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=10)
3130
for _ in range(1000)]
32-
range_it = xrange(loops)
31+
range_it = range(loops)
3332
t0 = pyperf.perf_counter()
3433

3534
for _ in range_it:

pyperformance/benchmarks/bm_go.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def best_visited(self):
414414

415415
# def user_move(board):
416416
# while True:
417-
# text = six.moves.input('?').strip()
417+
# text = input('?').strip()
418418
# if text == 'p':
419419
# return PASS
420420
# if text == 'q':

0 commit comments

Comments
 (0)