Skip to content

Commit

Permalink
gh-92546: Move pprint benchmark into pyperformance (GH-94613)
Browse files Browse the repository at this point in the history
This PR couples with python/pyperformance#222 and supersedes #92560. Inspired by #93096 (comment).

Automerge-Triggered-By: GH:ericsnowcurrently
  • Loading branch information
arhadthedev authored Jul 25, 2022
1 parent 4e704d7 commit c514094
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
16 changes: 0 additions & 16 deletions Lib/pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,19 +637,6 @@ def _recursion(object):
% (type(object).__name__, id(object)))


def _perfcheck(object=None):
import time
if object is None:
object = [("string", (1, 2), [3, 4], {5: 6, 7: 8})] * 100000
p = PrettyPrinter()
t1 = time.perf_counter()
p._safe_repr(object, {}, None, 0, True)
t2 = time.perf_counter()
p.pformat(object)
t3 = time.perf_counter()
print("_safe_repr:", t2 - t1)
print("pformat:", t3 - t2)

def _wrap_bytes_repr(object, width, allowance):
current = b''
last = len(object) // 4 * 4
Expand All @@ -666,6 +653,3 @@ def _wrap_bytes_repr(object, width, allowance):
current = candidate
if current:
yield repr(current)

if __name__ == "__main__":
_perfcheck()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An undocumented ``python -m pprint`` benchmark is moved into ``pprint``
suite of pyperformance. Patch by Oleg Iarygin.

0 comments on commit c514094

Please sign in to comment.