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)
| 64 | |
| 65 | |
| 66 | def 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 | |
| 80 | def _chaindict(mapping, |