Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Benchmark _safe_repr only if it exists
  • Loading branch information
arhadthedev committed Jul 7, 2022
commit 862dfc2e2c92d35f77a3d7767668764c7dae722e
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def benchmark_pprint(runner):
printable = [("string", (1, 2), [3, 4], {5: 6, 7: 8})] * 100_000
p = PrettyPrinter()

runner.bench_func('_safe_repr', p._safe_repr, printable, {}, None, 0)
# Support CPython before 3.10 and non-CPython implementations
if hasattr(p, '_safe_repr'):
runner.bench_func('_safe_repr', p._safe_repr, printable, {}, None, 0)
runner.bench_func('pformat', p.pformat, printable)


Expand Down