-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
Add proper caching to LocaleDataMap #16982
Conversation
WalkthroughThe recent enhancements to the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Thanks for such quick work, @LeonarddeR! |
source/characterProcessing.py
Outdated
@@ -34,6 +34,8 @@ | |||
class LocaleDataMap(Generic[_LocaleDataT], object): | |||
"""Allows access to locale-specific data objects, dynamically loading them if needed on request""" | |||
|
|||
_noDataLocalesCache: set[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason why this was added to the class rather than kept in __init__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only a type hint, the set itself is initiated in __init__
or should I provide the type hint in __init__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally the type hint would go in __init__
though right?
Link to issue number:
Fixes #16981
Follow up of #16823
Summary of the issue:
Since #16823, the log is spammed with errors re loading of nonexistent symbol dictionaries.
Description of user facing changes
No spamming with errors in the log.
Description of development approach
Before #16823, there were sets for caching locales without symbol dictionaries. When no dictionaries existed, the locales were saved in the cache and upon next request,
_getSpeechSymbolsForLocale
returned early.That caching mechanism was apparently removed in #16823. I now restored similar caching, but the cache is now stored on the
LocaleDataMap
instance. This should also be beneficial for character descriptions.Testing strategy:
Ensured that the error @XLTechie had only occurs once per dictionary.
Known issues with pull request:
None known
Code Review Checklist:
Summary by CodeRabbit
New Features
Bug Fixes