Skip to content

Added LRU caching of converted prompt-toolkit styles and colors.#1657

Merged
kmvanbrunt merged 3 commits intomainfrom
pt_style_cache
May 9, 2026
Merged

Added LRU caching of converted prompt-toolkit styles and colors.#1657
kmvanbrunt merged 3 commits intomainfrom
pt_style_cache

Conversation

@kmvanbrunt
Copy link
Copy Markdown
Member

No description provided.

@kmvanbrunt kmvanbrunt requested a review from tleonhardt as a code owner May 9, 2026 15:29
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.52%. Comparing base (5e3c8de) to head (bd347a3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1657   +/-   ##
=======================================
  Coverage   99.52%   99.52%           
=======================================
  Files          21       21           
  Lines        4810     4813    +3     
=======================================
+ Hits         4787     4790    +3     
  Misses         23       23           
Flag Coverage Δ
unittests 99.52% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kmvanbrunt kmvanbrunt changed the title Sync prompt-toolkit styles using LRU caching instead of callbacks. Sync prompt-toolkit styles on-demand using caching and LRU-backed lookups instead of callbacks May 9, 2026
@kmvanbrunt kmvanbrunt changed the title Sync prompt-toolkit styles on-demand using caching and LRU-backed lookups instead of callbacks Sync prompt-toolkit styles on demand using caching and LRU-backed lookups instead of callbacks May 9, 2026
Copy link
Copy Markdown
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I love the couple places you added an @lru_cache and think that is a very smart idea.

However, I strongly prefer the callback approach in the couple places it was used versus the approach here. The callback approach never wastes any time calling any code to check if things changed when it doesn't need to. This approach here will still waste significant time checking when nothing has changed.

Comment thread cmd2/pt_utils.py
Comment thread cmd2/cmd2.py Outdated
Comment thread cmd2/pt_utils.py Outdated
@kmvanbrunt kmvanbrunt changed the title Sync prompt-toolkit styles on demand using caching and LRU-backed lookups instead of callbacks Added LRU caching of converted prompt-toolkit styles and colors. May 9, 2026
Copy link
Copy Markdown
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I wasn't aware of Sytle.null()

@kmvanbrunt kmvanbrunt merged commit 06b4915 into main May 9, 2026
30 of 33 checks passed
@kmvanbrunt kmvanbrunt deleted the pt_style_cache branch May 9, 2026 19:23
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