Skip to content

Commit 0318d44

Browse files
authored
Add support for Python 3.11 (gh-142)
1 parent f0a9111 commit 0318d44

File tree

14 files changed

+20
-29
lines changed

14 files changed

+20
-29
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
15-
python: ['3.10']
15+
python: ['3.11']
1616
include:
17-
- os: ubuntu-latest
18-
python: '3.6'
1917
- os: ubuntu-latest
2018
python: '3.7'
2119
- os: ubuntu-latest
2220
python: '3.8'
2321
- os: ubuntu-latest
2422
python: '3.9'
23+
- os: ubuntu-latest
24+
python: '3.10'
2525

2626
steps:
2727
- uses: actions/checkout@v2

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Command to install pyperf on Python 3::
128128

129129
python3 -m pip install pyperf
130130

131-
pyperf requires Python 3.6 or newer.
131+
pyperf requires Python 3.7 or newer.
132132

133133
Python 2.7 users can use pyperf 1.7.1 which is the last version compatible with
134134
Python 2.7.

pyperf/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def cmd_hist(args):
580580
checks=checks):
581581
print(line)
582582

583-
if not(is_last or ignored):
583+
if not (is_last or ignored):
584584
print()
585585

586586
for suite, ignored in ignored:
@@ -691,7 +691,7 @@ def cmd_convert(args):
691691
for benchmark in suite:
692692
benchmark._remove_all_metadata()
693693

694-
compact = not(args.indent)
694+
compact = not args.indent
695695
if args.output_filename:
696696
suite.dump(args.output_filename, compact=compact)
697697
else:

pyperf/_bench.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Run(object):
9393

9494
def __init__(self, values, warmups=None,
9595
metadata=None, collect_metadata=True):
96-
if any(not(isinstance(value, NUMBER_TYPES) and value > 0)
96+
if any(not (isinstance(value, NUMBER_TYPES) and value > 0)
9797
for value in values):
9898
raise ValueError("values must be a sequence of number > 0.0")
9999

@@ -425,7 +425,7 @@ def median_abs_dev(self):
425425
return value
426426

427427
def percentile(self, p):
428-
if not(0 <= p <= 100):
428+
if not (0 <= p <= 100):
429429
raise ValueError("p must be in the range [0; 100]")
430430
return percentile(self.get_values(), p / 100.0)
431431

pyperf/_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def format_stats(bench, lines):
255255
else:
256256
text = "%s (average)" % total_loops
257257

258-
if not(isinstance(inner_loops, int) and inner_loops == 1):
258+
if not (isinstance(inner_loops, int) and inner_loops == 1):
259259
if isinstance(loops, int):
260260
loops = format_number(loops, 'outer-loop')
261261
else:
@@ -324,7 +324,7 @@ def format_limit(mean, value):
324324
iqr = q3 - q1
325325
outlier_min = (q1 - 1.5 * iqr)
326326
outlier_max = (q3 + 1.5 * iqr)
327-
noutlier = sum(not(outlier_min <= value <= outlier_max)
327+
noutlier = sum(not (outlier_min <= value <= outlier_max)
328328
for value in values)
329329
bounds = bench.format_values((outlier_min, outlier_max))
330330
lines.append('Number of outlier (out of %s..%s): %s'

pyperf/_compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def compare_suites_list(self, all_results):
395395
for result in results:
396396
lines.extend(result.format(self.verbose))
397397

398-
if not(significant or self.verbose):
398+
if not (significant or self.verbose):
399399
not_significant.append(results.name)
400400
continue
401401

@@ -472,7 +472,7 @@ def compare(self):
472472
]
473473
self.compare_suites(all_results)
474474
print()
475-
display_title(f"All benchmarks:")
475+
display_title("All benchmarks:")
476476
self.compare_suites(self.all_results)
477477

478478
if not self.quiet:

pyperf/_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def spawn_worker(self, calibrate_loops, calibrate_warmups):
9292
# bInheritHandles=True. For pass_handles, see
9393
# http://bugs.python.org/issue19764
9494
kw['close_fds'] = False
95-
elif sys.version_info >= (3, 2):
95+
else:
9696
kw['pass_fds'] = [wpipe.fd]
9797

9898
proc = subprocess.Popen(cmd, env=env, **kw)

pyperf/_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def median_abs_dev(values):
371371

372372

373373
def percentile(values, p):
374-
if not isinstance(p, float) or not(0.0 <= p <= 1.0):
374+
if not isinstance(p, float) or not (0.0 <= p <= 1.0):
375375
raise ValueError("p must be a float in the range [0.0; 1.0]")
376376

377377
values = sorted(values)
@@ -427,4 +427,3 @@ def merge_profile_stats(profiler, dst):
427427
dst_stats.dump_stats(dst)
428428
else:
429429
profiler.dump_stats(dst)
430-

pyperf/_worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_calibrate_warmups(self, nwarmup, unit):
133133
iqr = q3 - q1
134134
outlier_max = (q3 + 1.5 * iqr)
135135
# only check maximum, not minimum
136-
outlier = not(first_value <= outlier_max)
136+
outlier = not (first_value <= outlier_max)
137137

138138
mean1 = statistics.mean(sample1)
139139
mean2 = statistics.mean(sample2)
@@ -185,7 +185,7 @@ def test_calibrate_warmups(self, nwarmup, unit):
185185

186186
if outlier:
187187
return False
188-
if not(-0.5 <= mean_diff <= 0.10):
188+
if not (-0.5 <= mean_diff <= 0.10):
189189
return False
190190
if abs(mad_diff) > 0.10:
191191
return False

pyperf/tests/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
def _capture_stream(name):
1616
old_stream = getattr(sys, name)
1717
try:
18-
if sys.version_info >= (3,):
19-
stream = io.StringIO()
20-
else:
21-
stream = io.BytesIO()
18+
stream = io.StringIO()
2219
setattr(sys, name, stream)
2320
yield stream
2421
finally:

0 commit comments

Comments
 (0)