You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR contains only the new internal-facing module effectful.internals.weak and its tests tests/test_internals_weak.py from #743. This module and its tests are self-contained and do not depend on any other part of effectful; no changes here affect the rest of the library in any way.
Most of the implementation of internals.weak.WeakIdKeyDictionary is copied from torch.utils.weak, although I've made some fixes and cleaned up types and docstrings. The things on top of that are new.
I haven't read this code in detail, just put it through GPT.
The nastiest part of the code is the implementation of WeakIdKeyDictionary (including _iterationGuard and WeakIdRef) which is a forked and lightly modified version of torch.utils.weak.WeakIdKeyDictionary and thus shouldn't need careful review. The other stuff in weak.py is more straightforward and largely sits on top of that. The tests were generated by Claude from a specification I wrote and reviewed with/for it, along with the tests from PyTorch for torch.utils.weak (which are not exactly comprehensive). I am never thrilled with Claude's test code but I think it covered everything in the spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Factored out of #743 to ease review.
This PR contains only the new internal-facing module
effectful.internals.weakand its teststests/test_internals_weak.pyfrom #743. This module and its tests are self-contained and do not depend on any other part ofeffectful; no changes here affect the rest of the library in any way.Most of the implementation of
internals.weak.WeakIdKeyDictionaryis copied fromtorch.utils.weak, although I've made some fixes and cleaned up types and docstrings. The things on top of that are new.