Merged
Conversation
Collaborator
Author
|
@cdrini I'm fairly confident in this PR but I'd love a second set of eyes on this by you! |
Closed
cdrini
reviewed
Jan 21, 2026
RayBB
commented
Jan 21, 2026
RayBB
commented
Jan 21, 2026
Co-authored-by: Drini Cami <cdrini@gmail.com>
Collaborator
Author
|
@cdrini rename done |
cdrini
approved these changes
Feb 11, 2026
Collaborator
cdrini
left a comment
There was a problem hiding this comment.
Lgtm! Tested on testing. Woohoo, another duplicate caching function down!
bhardwajparth51
added a commit
to bhardwajparth51/openlibrary
that referenced
this pull request
Feb 17, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #11479
Some of this text was AI generated but I've closely guided and monitored the changes.
Remove
method_memoizeand Replace with Standard Python CachingSummary
This PR removes the custom
method_memoizedecorator from the codebase and replaces it with standard Python caching patternsfunctools.cached_property.Changes
Production Code
openlibrary/core/models.py:@cache.method_memoizewith@functools.cached_propertyon:Thing.get_history_preview()Work.edition_countget_history_previewas a property instead of a method callWhy It's Safe
What it does:
functools.cached_propertycaches the result in the instance's__dict__on first access. Subsequent accesses return the cached value without recomputing.Why it's safe:
method_memoizefor methods with no argumentsPerformance Considerations
As far as I know, there is no risk of performance changes.
Testing
Poking around the local website and looking at history and editions everything seems fine.
Stakeholders
@cdrini