MCPcopy
hub / github.com/celery/celery / saferepr

Function saferepr

celery/utils/saferepr.py:66–77  ·  view source on GitHub ↗

Safe version of :func:`repr`. Warning: Make sure you set the maxlen argument, or it will be very slow for recursive objects. With the maxlen set, it's often faster than built-in repr.

(o, maxlen=None, maxlevels=3, seen=None)

Source from the content-addressed store, hash-verified

64
65
66def saferepr(o, maxlen=None, maxlevels=3, seen=None):
67 # type: (Any, int, int, Set) -> str
68 """Safe version of :func:`repr`.
69
70 Warning:
71 Make sure you set the maxlen argument, or it will be very slow
72 for recursive objects. With the maxlen set, it's often faster
73 than built-in repr.
74 """
75 return ''.join(_saferepr(
76 o, maxlen=maxlen, maxlevels=maxlevels, seen=seen
77 ))
78
79
80def _chaindict(mapping,

Callers 15

test_safe_typesMethod · 0.90
test_numbers_dictMethod · 0.90
test_numbers_listMethod · 0.90
test_numbers_keysMethod · 0.90
test_textMethod · 0.90
test_text_maxlenMethod · 0.90
test_maxlevelsMethod · 0.90
test_recursionMethod · 0.90
test_same_as_reprMethod · 0.90
test_single_quoteMethod · 0.90
test_unicode_bytesMethod · 0.90

Calls 2

_safereprFunction · 0.85
joinMethod · 0.45

Tested by 15

test_safe_typesMethod · 0.72
test_numbers_dictMethod · 0.72
test_numbers_listMethod · 0.72
test_numbers_keysMethod · 0.72
test_textMethod · 0.72
test_text_maxlenMethod · 0.72
test_maxlevelsMethod · 0.72
test_recursionMethod · 0.72
test_same_as_reprMethod · 0.72
test_single_quoteMethod · 0.72
test_unicode_bytesMethod · 0.72