Skip to content

Commit f2ed187

Browse files
committed
Misc Python 2 removal cleanups
* Fix flake8 warnings * Fix tox command in setup.py * Update requirements
1 parent 89f2afd commit f2ed187

File tree

7 files changed

+9
-49
lines changed

7 files changed

+9
-49
lines changed

pyperformance/benchmarks/__init__.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -304,27 +304,6 @@ def get_benchmarks():
304304
return (bench_funcs, bench_groups)
305305

306306

307-
def filter_benchmarks(benchmarks, bench_funcs, base_ver):
308-
"""Filters out benchmarks not supported by both Pythons.
309-
310-
Args:
311-
benchmarks: a set() of benchmark names
312-
bench_funcs: dict mapping benchmark names to functions
313-
python: the interpereter commands (as lists)
314-
315-
Returns:
316-
The filtered set of benchmark names
317-
"""
318-
for bm in list(benchmarks):
319-
func = bench_funcs[bm]
320-
if getattr(func, '_python2_only', False) and (3, 0) <= base_ver:
321-
benchmarks.discard(bm)
322-
logging.info("Skipping Python2-only benchmark %s; "
323-
"not compatible with Python %s" % (bm, base_ver))
324-
continue
325-
return benchmarks
326-
327-
328307
def expand_benchmark_name(bm_name, bench_groups):
329308
"""Recursively expand name benchmark names.
330309

pyperformance/benchmarks/bm_hg_startup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def get_hg_version(hg_bin):
99
# Fast-path: use directly the Python module
1010
try:
1111
from mercurial.__version__ import version
12-
if sys.version_info >= (3,) and isinstance(version, bytes):
12+
if isinstance(version, bytes):
1313
return version.decode('utf8')
1414
else:
1515
return version

pyperformance/benchmarks/bm_xml_etree.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def add_cmdline_args(cmd, args):
230230
"Default is '%s'" % default_etmodule)
231231
parser.add_argument("--no-accelerator", action="store_true", default=False,
232232
help="Disable the '_elementree' accelerator module "
233-
"for ElementTree in Python 3.3+.")
233+
"for ElementTree.")
234234
parser.add_argument("benchmark", nargs='?', choices=BENCHMARKS)
235235

236236
options = runner.parse_args()
@@ -270,7 +270,6 @@ def import_module(module_name):
270270
if options.no_accelerator:
271271
accelerator = False
272272
else:
273-
# Python 3.0-3.2 always use the accelerator
274273
accelerator = True
275274
if accelerator:
276275
module += ' (with C accelerator)'

pyperformance/cli_run.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@
55
import pyperf
66

77
import pyperformance
8-
from pyperformance.benchmarks import (filter_benchmarks, get_benchmarks,
9-
select_benchmarks)
8+
from pyperformance.benchmarks import get_benchmarks, select_benchmarks
109
from pyperformance.compare import display_benchmark_suite
1110
from pyperformance.run import run_benchmarks
1211

1312

14-
def filter_benchmarks_python(benchmarks, bench_funcs):
15-
return filter_benchmarks(benchmarks, bench_funcs, sys.version_info)
16-
17-
1813
def get_benchmarks_to_run(options):
1914
bench_funcs, bench_groups = get_benchmarks()
2015
should_run = select_benchmarks(options.benchmarks, bench_groups)
21-
should_run = filter_benchmarks_python(should_run, bench_funcs)
2216
return (bench_funcs, bench_groups, should_run)
2317

2418

@@ -71,7 +65,7 @@ def cmd_list_groups(options):
7165
bench_funcs, bench_groups = get_benchmarks()
7266

7367
funcs = set(bench_groups['all'])
74-
all_funcs = filter_benchmarks_python(set(funcs), bench_funcs)
68+
all_funcs = set(funcs)
7569

7670
for group, funcs in sorted(bench_groups.items()):
7771
funcs = set(funcs) & all_funcs

pyperformance/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ psutil==5.6.7
1919
pyaes==1.6.1
2020
pyperf==1.7.0
2121
pytz==2019.3 # via django
22-
six==1.14.0
22+
six==1.14.0 # via html5lib, pyperf
2323
sqlalchemy==1.3.13
2424
sqlparse==0.3.0 # via django
2525
sympy==1.5.1

pyperformance/venv.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import errno
22
import os
3-
import platform
43
import shutil
54
import subprocess
65
import sys
@@ -81,12 +80,7 @@ def safe_rmtree(path):
8180

8281

8382
def python_implementation():
84-
if hasattr(sys, 'implementation'):
85-
# PEP 421, Python 3.3
86-
name = sys.implementation.name
87-
else:
88-
name = platform.python_implementation()
89-
return name.lower()
83+
return sys.implementation.name.lower()
9084

9185

9286
def get_venv_program(program):
@@ -213,22 +207,16 @@ def get_path(self):
213207

214208
script = textwrap.dedent("""
215209
import hashlib
216-
import platform
217210
import sys
218211
219212
performance_version = sys.argv[1]
220213
requirements = sys.argv[2]
221214
222215
data = performance_version + sys.executable + sys.version
223216
224-
pyver= sys.version_info
217+
pyver = sys.version_info
225218
226-
if hasattr(sys, 'implementation'):
227-
# PEP 421, Python 3.3
228-
implementation = sys.implementation.name
229-
else:
230-
implementation = platform.python_implementation()
231-
implementation = implementation.lower()
219+
implementation = sys.implementation.name.lower()
232220
233221
if not isinstance(data, bytes):
234222
data = data.encode('utf-8')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# - maybe update version in pyperformance/__init__.py and doc/conf.py
1919
# - set release date in doc/changelog.rst
2020
# - git commit -a -m "prepare release x.y"
21-
# - run tests: tox --parallel 0
21+
# - run tests: tox --parallel auto
2222
# - git push
2323
# - check Travis CI status:
2424
# https://travis-ci.org/python/pyperformance

0 commit comments

Comments
 (0)