-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Fix finding location of translations #204
Fix finding location of translations #204
Conversation
af19aaf
to
ff870da
Compare
Fixes python-humanize#105 Use importlib.resources available since Python 3.9 to find the location of the locale folder containing the translations.
ff870da
to
9627694
Compare
I tried to use The tests cover when |
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.
Thanks for this!
Let's do some tuning to speed up with lazy imports, which can be important for CLIs where you want a quick response time.
Using https://github.com/nschloe/tuna we can visualise the import times:
python -m pip install tuna
python -c "import humanize" && python -X importtime -c "import humanize" 2> import.log && tuna import.log
Here's main
:
Here's this PR:
With the suggestions:
Improve import times Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Hi, Thank you for the review. I had not considered the CLI aspect of humanize. That's a good point. Now a CLI user will pay the price of importing if TYPE_CHECKING:
import os
import pathlib is really useful here. Thank you for showing me tuna. I did not know this tool, and I've used snakeViz in the past, so it's great to see a better alternative. Also this is the first time I see |
I can also imagine some CLI users don't use i18n so might not run touch this. Even for code that might run more often, lazy imports can make Yeah, tuna is really nice for visualising import times along with Thanks for the PR! |
Fixes #105
Changes proposed in this pull request:
importlib.resources
available since Python 3.9 to find the location of the locale folder containing the translations.