Skip to content

Add lru-cache-python materials folder - #986

Merged
realpython-bot merged 2 commits into
masterfrom
maintenance/lru-cache-python-20261203
Dec 3, 2026
Merged

realpython-bot merged 2 commits into
masterfrom
maintenance/lru-cache-python-20261203

Conversation

@realpython-bot

Copy link
Copy Markdown
Collaborator

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() to datetime.now(timezone.utc) in timed_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.py prints the expected fetch-once output.
  • stairs.py prints 53798080 and a timing, stairs_lru_cache.py the same with a sub-microsecond timing, stairs_cache_info.py prints CacheInfo(hits=52, misses=30, maxsize=16, currsize=16) as in the tutorial.
  • monitor.py and monitor_cached.py ran 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), and dircheck.py pass.

🤖 Generated with Claude Code

realpython-bot and others added 2 commits December 3, 2026 06:14
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>
@realpython-bot
realpython-bot merged commit e4f0a1f into master Dec 3, 2026
1 check passed
@realpython-bot
realpython-bot deleted the maintenance/lru-cache-python-20261203 branch December 3, 2026 07:08
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.

1 participant