@@ -149,8 +149,9 @@ def __init__(self, indent=1, width=80, depth=None, stream=None, *,
149149 self ._underscore_numbers = underscore_numbers
150150
151151 def pprint (self , object ):
152- self ._format (object , self ._stream , 0 , 0 , {}, 0 )
153- self ._stream .write ("\n " )
152+ if self ._stream is not None :
153+ self ._format (object , self ._stream , 0 , 0 , {}, 0 )
154+ self ._stream .write ("\n " )
154155
155156 def pformat (self , object ):
156157 sio = _StringIO ()
@@ -636,19 +637,6 @@ def _recursion(object):
636637 % (type (object ).__name__ , id (object )))
637638
638639
639- def _perfcheck (object = None ):
640- import time
641- if object is None :
642- object = [("string" , (1 , 2 ), [3 , 4 ], {5 : 6 , 7 : 8 })] * 100000
643- p = PrettyPrinter ()
644- t1 = time .perf_counter ()
645- p ._safe_repr (object , {}, None , 0 , True )
646- t2 = time .perf_counter ()
647- p .pformat (object )
648- t3 = time .perf_counter ()
649- print ("_safe_repr:" , t2 - t1 )
650- print ("pformat:" , t3 - t2 )
651-
652640def _wrap_bytes_repr (object , width , allowance ):
653641 current = b''
654642 last = len (object ) // 4 * 4
@@ -665,6 +653,3 @@ def _wrap_bytes_repr(object, width, allowance):
665653 current = candidate
666654 if current :
667655 yield repr (current )
668-
669- if __name__ == "__main__" :
670- _perfcheck ()
0 commit comments