Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling cycles in objects #24

Open
viraptor opened this issue Nov 9, 2024 · 1 comment
Open

Handling cycles in objects #24

viraptor opened this issue Nov 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@viraptor
Copy link

viraptor commented Nov 9, 2024

Currently the implementation will happily descend into the objects forever.
It would be great if it handled cycles by keeping a history of which objects are already being traversed.

So something like:

foo = {'a': None, 'b': 123}
foo['a'] = foo

Would ensure that b has the same value, but a points at the same object in the path. Or specifically at an object the same number of steps up the path.

fooL = {'a': None, 'b': 123}
fooL['a'] = fooL
fooR = {'a': None, 'b': 123}
fooR['a'] = fooR
recursive_diff(fooL, fooR) <- should find no differences and not get stuck
@crusaderky
Copy link
Owner

Thanks for spotting this! Would you be available to write a PR?

@crusaderky crusaderky added the bug Something isn't working label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants