Skip to content

Use deque for O(1) cache eviction#13

Merged
chrislyonsKY merged 1 commit into
mainfrom
feature/cache-improvements
Mar 13, 2026
Merged

Use deque for O(1) cache eviction#13
chrislyonsKY merged 1 commit into
mainfrom
feature/cache-improvements

Conversation

@chrislyonsKY
Copy link
Copy Markdown
Owner

Summary

  • Replace list with collections.deque for cache eviction order — popleft() is O(1) vs list.pop(0) which is O(n)
  • Move contextlib import to module level (was inside _evict())

Test plan

  • All 9 cache tests pass
  • ruff + mypy clean

🤖 Generated with Claude Code

- Replace list with collections.deque for _order tracking —
  popleft() is O(1) vs list.pop(0) which is O(n)
- Move contextlib import to module level instead of inside _evict()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chrislyonsKY chrislyonsKY merged commit dca2a95 into main Mar 13, 2026
2 of 3 checks passed
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