Skip to main content

reprstream

Streaming repr, yielding tokens.

def reprstream(
stack: deque,
seen: Optional[Set],
maxlevels: int,
level: int,
isinstance: Callable
) - > Iterator[Any]

Streaming repr, yielding tokens.

Parameters

NameTypeDescription
stackdequeA double-ended queue containing iterables to be processed, used to manage the traversal of nested data structures.
seenOptional[Set]A set of object memory addresses used to track visited objects and prevent infinite recursion in circular references.
maxlevelsintThe maximum depth of nested objects to traverse before truncating the output with an ellipsis.
levelintThe current nesting depth level during the recursive traversal.
isinstanceCallableThe function used for type checking, typically the built-in isinstance.

Returns

TypeDescription
Iterator[Any]An iterator yielding pairs of tokens (strings or literal markers) and the current iterable being processed.