detect_changed_props

function
yoltra/diff.py:51
signature
detect_changed_props(old, new, path?, ancestors?): str[]

Return the dotted leaf paths that changed between `old` and `new`.

Parameters

NameTypeDescription
oldanyPrevious value.
NameTypeDescription
newanyNext value.
NameTypeDescription
path?strCurrent dotted path; callers pass `""` for the root and recursion appends segments.
NameTypeDescription
ancestors?dict<int, set<int>> | NoneCycle-detection state (`id(old) -> {id(new), ...}` pairs on the current recursion path). Callers never pass this.

Returns

str[]A list of dotted leaf paths that changed (`"."`-separated, integer segments for sequences, e.g. `"todos.0.title"`). `[]` if nothing changed. Paths form a set for the caller's purposes; order is not significant.

Example

example
>>> detect_changed_props(
...     {"user": {"name": "Ada", "age": 37}},
...     {"user": {"name": "Grace", "age": 37}},
... )
['user.name']
>>> detect_changed_props({"nums": [1, 2]}, {"nums": [1, 2, 3]})
['nums']