return "{...}", False, objid in context
return _recursion(object), False, True
append = components.append
items = sorted(object.items(), key=_safe_tuple)
krepr, kreadable, krecur = saferepr(k, context, maxlevels, level)
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
append("%s: %s" % (krepr, vrepr))
readable = readable and kreadable and vreadable
return "{%s}" % ", ".join(components), readable, recursive
if (issubclass(typ, list) and r is list.__repr__) or \
(issubclass(typ, tuple) and r is tuple.__repr__):
if issubclass(typ, list):
if maxlevels and level >= maxlevels:
return format % "...", False, objid in context
return _recursion(object), False, True
append = components.append
orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level)
return format % ", ".join(components), readable, recursive
return rep, (rep and not rep.startswith('<')), False
_builtin_scalars = frozenset({str, bytes, bytearray, int, float, complex,
return ("<Recursion on %s with id=%s>"
% (type(object).__name__, id(object)))
def _perfcheck(object=None):
object = [("string", (1, 2), [3, 4], {5: 6, 7: 8})] * 100000
_safe_repr(object, {}, None, 0)
print("_safe_repr:", t2 - t1)
print("pformat:", t3 - t2)
def _wrap_bytes_repr(object, width, allowance):
last = len(object) // 4 * 4
for i in range(0, len(object), 4):
candidate = current + part
if len(repr(candidate)) > width:
if __name__ == "__main__":