MCPcopy Index your code
hub / github.com/python/cpython / _iterencode

Function _iterencode

Lib/json/encoder.py:415–449  ·  view source on GitHub ↗
(o, _current_indent_level)

Source from the content-addressed store, hash-verified

413 del markers[markerid]
414
415 def _iterencode(o, _current_indent_level):
416 if isinstance(o, str):
417 yield _encoder(o)
418 elif o is None:
419 yield 'null'
420 elif o is True:
421 yield 'true'
422 elif o is False:
423 yield 'false'
424 elif isinstance(o, int):
425 # see comment for int/float in _make_iterencode
426 yield int.__repr__(o)
427 elif isinstance(o, float):
428 # see comment for int/float in _make_iterencode
429 yield _floatstr(o)
430 elif isinstance(o, (list, tuple)):
431 yield from _iterencode_list(o, _current_indent_level)
432 elif isinstance(o, (dict, frozendict)):
433 yield from _iterencode_dict(o, _current_indent_level)
434 else:
435 if markers is not None:
436 markerid = id(o)
437 if markerid in markers:
438 raise ValueError("Circular reference detected")
439 markers[markerid] = o
440 newobj = _default(o)
441 try:
442 yield from _iterencode(newobj, _current_indent_level)
443 except GeneratorExit:
444 raise
445 except BaseException as exc:
446 exc.add_note(f'when serializing {type(o).__name__} object')
447 raise
448 if markers is not None:
449 del markers[markerid]
450
451 def _iterencode_once(o, _current_indent_level):
452 nonlocal _iterencode, _iterencode_dict, _iterencode_list

Callers 4

iterencodeMethod · 0.85
_iterencode_listFunction · 0.85
_iterencode_dictFunction · 0.85
_iterencode_onceFunction · 0.85

Calls 4

_iterencode_listFunction · 0.85
_iterencode_dictFunction · 0.85
idFunction · 0.85
__repr__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…