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

Use importlib.metadata to get package version instead of pkg_resources.get_distribution to decrease memory consumption #227

Merged
merged 4 commits into from
Oct 6, 2021

Conversation

akayunov
Copy link

@akayunov akayunov commented Oct 5, 2021

pkg_resources use a lot of memory and after introducing importlib.metadata in 3.8 looks obsolete. So let's change way to get package version and get rid of pkg_resources import.

…ersion instead of pkg_resources.get_dictribution
@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2021

Codecov Report

Merging #227 (cdf0328) into master (62e9915) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #227   +/-   ##
=======================================
  Coverage   99.68%   99.68%           
=======================================
  Files           9        9           
  Lines         632      636    +4     
=======================================
+ Hits          630      634    +4     
  Misses          2        2           
Flag Coverage Δ
GHA_Ubuntu 98.42% <100.00%> (+<0.01%) ⬆️
GHA_Windows 98.11% <100.00%> (+0.01%) ⬆️
GHA_macOS 98.42% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
src/humanize/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62e9915...cdf0328. Read the comment docs.

@hugovk
Copy link
Collaborator

hugovk commented Oct 5, 2021

Thank you for the PR! I agree, let's remove pkg_resources.

However, let's use the importlib_metadata backport instead for Python < 3.8, like prettytable/prettytable#96.

Please could you update the PR?

@hugovk hugovk added the changelog: Changed For changes in existing functionality label Oct 5, 2021
@akayunov
Copy link
Author

akayunov commented Oct 6, 2021

Done.

@hugovk
Copy link
Collaborator

hugovk commented Oct 6, 2021

Thanks, please can you move it to setup.cfg?

Something like:

[options]
install_requires =
    importlib-metadata;python_version < '3.8'

https://github.com/jazzband/prettytable/blob/5ce1d24d764aaff936077d0212bad56bd9626972/setup.cfg#L27-L31

@hugovk hugovk added the hacktoberfest-accepted To credit accepted Hacktoberfest PRs label Oct 6, 2021
@hugovk hugovk changed the title decrease memory consumption, use importlib.metadata to get package version instead of pkg_resources.get_dictribution Use importlib.metadata to get package version instead of pkg_resources.get_distribution to decrease memory consumption Oct 6, 2021
@hugovk hugovk merged commit a83b85c into jmoiron:master Oct 6, 2021
@hugovk
Copy link
Collaborator

hugovk commented Oct 6, 2021

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Changed For changes in existing functionality hacktoberfest-accepted To credit accepted Hacktoberfest PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants