Update pprint.py from CPython v3.12.0a0

This commit is contained in:
Gyubong committed 2022-10-04 12:14:53 +09:00
1 parent ac2532822b
commit b0f620cd12
1 file changed
+3 -18
+3 -18
View File
@@ -149,8 +149,9 @@ class PrettyPrinter:
self._underscore_numbers = underscore_numbers
def pprint(self, object):
self._format(object, self._stream, 0, 0, {}, 0)
self._stream.write("\n")
if self._stream is not None:
self._format(object, self._stream, 0, 0, {}, 0)
self._stream.write("\n")
def pformat(self, object):
sio = _StringIO()
@@ -636,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
@@ -665,6 +653,3 @@ def _wrap_bytes_repr(object, width, allowance):
current = candidate
if current:
yield repr(current)
if __name__ == "__main__":
_perfcheck()