pg.Origin#
Accessible via pg.Origin
, pg.symbolic.Origin
.
- class Origin(source, tag, stacktrace=None, stacklimit=None, stacktop=-1)[source]#
Bases:
pg.Formattable
Class that represents the origin of a symbolic value.
Origin is used for debugging the creation chain of a symbolic value, as well as keeping track of the factory or builder in creational design patterns. An Origin object records the source value, a string tag, and optional stack information on where a symbolic value is created.
Built-in tags are ‘__init__’, ‘clone’, ‘deepclone’ and ‘return’. Users can pass custom tags to the sym_setorigin method of a symbolic value for tracking its source in their own scenarios.
When origin tracking is enabled by calling pg.track_origin(True), the sym_setorigin method of symbolic values will be automatically called during object creation, cloning or being returned from a functor. The stack information can be obtained by origin.stack or origin.stacktrace.
Methods:
chain
([tag])Get the origin list from the neareast to the farthest filtered by tag.
format
([compact, verbose, root_indent])Formats this object.
history
([condition])Returns a history of origins with an optional filter.
Attributes:
Returns the root source of the origin.
Returns the source object.
Returns the frame summary of original stack.
Returns stack trace string.
Returns tag.
- format(compact=False, verbose=True, root_indent=0, **kwargs)[source]#
Formats this object.
- Return type:
- property stack: List[FrameSummary] | None[source]#
Returns the frame summary of original stack.