Skip to content

Avoid @lru_cache on methods #9148

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

Merged
merged 2 commits into from
Oct 1, 2021
Merged

Conversation

bluetech
Copy link
Member

@bluetech bluetech commented Oct 1, 2021

The problem with @lru_cache on methods is that it also captures self and leaks it until the entry is evicted (if ever).

I was able to restore the caching in both cases (one straightforward case in the first commit, the other in the second commit).

The problem with `@lru_cache` on methods is that it also captures `self`
and leaks it until the entry is evicted (if ever).
Now that it's no longer using `@lru_cache`, use another check to avoid
re-computation. Although `@lru_cache` is faster than the full function
call + checks, this approach also has the advantage that the caching
works for more than 128 entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants