Skip to content

Commit

Permalink
Remove usage of the six module
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Mar 19, 2020
1 parent 7dbb76d commit f1006e6
Show file tree
Hide file tree
Showing 42 changed files with 271 additions and 363 deletions.
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
Version 1.0.1
-------------

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

* Django: 3.0 => 3.0.3
Expand Down
5 changes: 2 additions & 3 deletions pyperformance/benchmarks/bm_chameleon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools

import six
import pyperf

from chameleon import PageTemplate
Expand All @@ -12,11 +11,11 @@
<tr tal:repeat="row python: options['table']">
<td tal:repeat="c python: row.values()">
<span tal:define="d python: c + 1"
tal:attributes="class python: 'column-' + %s(d)"
tal:attributes="class python: 'column-' + str(d)"
tal:content="python: d" />
</td>
</tr>
</table>""" % six.text_type.__name__
</table>"""


def main():
Expand Down
10 changes: 2 additions & 8 deletions pyperformance/benchmarks/bm_chaos.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import random

import pyperf
import six
from six.moves import xrange


DEFAULT_THICKNESS = 0.25
Expand Down Expand Up @@ -136,11 +134,7 @@ def write_ppm(im, filename):
w = len(im)
h = len(im[0])

if six.PY3:
fp = open(filename, "w", encoding="latin1", newline='')
else:
fp = open(filename, "wb")
with fp:
with open(filename, "w", encoding="latin1", newline='') as fp:
fp.write(magic)
fp.write('%i %i\n%i\n' % (w, h, maxval))
for j in range(h):
Expand Down Expand Up @@ -227,7 +221,7 @@ def create_image_chaos(self, w, h, iterations, filename, rng_seed):
im = [[1] * h for i in range(w)]
point = GVector((self.maxx + self.minx) / 2,
(self.maxy + self.miny) / 2, 0)
for _ in xrange(iterations):
for _ in range(iterations):
point = self.transform_point(point)
x = (point.x - self.minx) / self.width * w
y = (point.y - self.miny) / self.height * h
Expand Down
3 changes: 1 addition & 2 deletions pyperformance/benchmarks/bm_crypto_pyaes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import pyperf
from six.moves import xrange

import pyaes

Expand All @@ -18,7 +17,7 @@


def bench_pyaes(loops):
range_it = xrange(loops)
range_it = range(loops)
t0 = pyperf.perf_counter()

for loops in range_it:
Expand Down
3 changes: 1 addition & 2 deletions pyperformance/benchmarks/bm_django_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This will have Django generate a 150x150-cell HTML table.
"""

from six.moves import xrange
import pyperf

import django.conf
Expand All @@ -21,7 +20,7 @@ def bench_django_template(runner, size):
{% endfor %}
</table>
""")
table = [xrange(size) for _ in xrange(size)]
table = [range(size) for _ in range(size)]
context = Context({"table": table})

runner.bench_func('django_template', template.render, context)
Expand Down
7 changes: 3 additions & 4 deletions pyperformance/benchmarks/bm_fannkuch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
"""

import pyperf
from six.moves import xrange


DEFAULT_ARG = 9


def fannkuch(n):
count = list(xrange(1, n + 1))
count = list(range(1, n + 1))
max_flips = 0
m = n - 1
r = n
check = 0
perm1 = list(xrange(n))
perm = list(xrange(n))
perm1 = list(range(n))
perm = list(range(n))
perm1_ins = perm1.insert
perm1_pop = perm1.pop

Expand Down
3 changes: 1 addition & 2 deletions pyperformance/benchmarks/bm_float.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Artificial, floating point-heavy benchmark originally used by Factor.
"""
from six.moves import xrange
import pyperf

from math import sin, cos, sqrt
Expand Down Expand Up @@ -46,7 +45,7 @@ def maximize(points):

def benchmark(n):
points = [None] * n
for i in xrange(n):
for i in range(n):
points[i] = Point(i)
for p in points:
p.normalize()
Expand Down
3 changes: 1 addition & 2 deletions pyperformance/benchmarks/bm_genshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import pyperf
from six.moves import xrange

from genshi.template import MarkupTemplate, NewTextTemplate

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

for _ in range_it:
Expand Down
2 changes: 1 addition & 1 deletion pyperformance/benchmarks/bm_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def best_visited(self):

# def user_move(board):
# while True:
# text = six.moves.input('?').strip()
# text = input('?').strip()
# if text == 'p':
# return PASS
# if text == 'q':
Expand Down
Loading

0 comments on commit f1006e6

Please sign in to comment.