Repository navigation
Add lru-cache-python materials folder - #986
Merged
Merged
Conversation
Sample code for the Caching in Python Using the LRU Cache Strategy tutorial, mirroring the maintenance update draft (datetime.now(timezone.utc) instead of the deprecated datetime.utcnow()). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds the companion code for Caching in Python Using the LRU Cache Strategy, which had no materials folder.
The files mirror the maintenance update draft (admin: https://realpython.com/pbjt/blog/post/2762/change/), including the switch from the deprecated
datetime.utcnow()todatetime.now(timezone.utc)intimed_lru_cache(). Pins match the article's dependencies field:requests==2.34.2,feedparser==6.0.14.Trello card: https://trello.com/c/QBiTE5MP
Verification (Python 3.14, venv on the pinned requirements):
caching.pyprints the expected fetch-once output.stairs.pyprints53798080and a timing,stairs_lru_cache.pythe same with a sub-microsecond timing,stairs_cache_info.pyprintsCacheInfo(hits=52, misses=30, maxsize=16, currsize=16)as in the tutorial.monitor.pyandmonitor_cached.pyran against the live feed with-W error::DeprecationWarning; the cached version skips fetches within the 10-second window, as the tutorial shows.ruff format --check,ruff check(0.14.1), anddircheck.pypass.🤖 Generated with Claude Code