Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-work EmPy token caching #662

Merged
merged 2 commits into from
Sep 6, 2024
Merged

Re-work EmPy token caching #662

merged 2 commits into from
Sep 6, 2024

Conversation

cottsay
Copy link
Member

@cottsay cottsay commented Sep 6, 2024

The previous approach was to re-implement Interpreter.parse() to iterate over cached tokens where possible. This proved to be a problem when the implementation changed in EmPy 4.x.

The approach implemented here is to create a shim between the Interpreter and Scanner API and record/inject the tokens there, which improves the compatibility by working only at the API boundary and not duplicating chunks of the upstream implementation.

Note that I haven't actually benchmarked either of these caching implementations. They may not be worth the complexity.

The previous approach was to re-implement Interpreter.parse() to iterate
over cached tokens where possible. This proved to be a problem when the
implementation changed in EmPy 4.x.

The approach implemented here is to create a shim between the
Interpreter and Scanner API and record/inject the tokens there, which
improves the compatibility by working only at the API boundary and not
duplicating chunks of the upstream implementation.
@cottsay cottsay added the enhancement New feature or request label Sep 6, 2024
@cottsay cottsay added this to the 0.17.2 milestone Sep 6, 2024
@cottsay cottsay requested a review from clalancette September 6, 2024 19:12
@cottsay cottsay self-assigned this Sep 6, 2024
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.36%. Comparing base (4d7ab92) to head (1e6c9b9).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #662      +/-   ##
==========================================
+ Coverage   87.34%   87.36%   +0.01%     
==========================================
  Files          67       67              
  Lines        3913     3917       +4     
  Branches      776      775       -1     
==========================================
+ Hits         3418     3422       +4     
  Misses        391      391              
  Partials      104      104              

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

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

I've left one style thing to consider. Otherwise, this seems like a more compatible approach for Empy 3 and 4, so thanks for that!

colcon_core/shell/template/__init__.py Outdated Show resolved Hide resolved
@cottsay cottsay merged commit 7cb836e into master Sep 6, 2024
36 checks passed
@cottsay cottsay deleted the cottsay/empy-token-cache branch September 6, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants