Skip to content

Commit

Permalink
#decrease memory consumption, use importlib.metadata to get package v…
Browse files Browse the repository at this point in the history
…ersion instead of pkg_resources.get_dictribution
  • Loading branch information
akayunov committed Oct 5, 2021
1 parent 62e9915 commit cdf0328
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/humanize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Main package for humanize."""
import pkg_resources
import sys

from humanize.filesize import naturalsize
from humanize.i18n import activate, deactivate, thousands_separator
Expand All @@ -20,7 +20,12 @@
precisedelta,
)

__version__ = VERSION = pkg_resources.get_distribution(__name__).version
if sys.version_info >= (3, 8, 0):
from importlib.metadata import version
__version__ = version(__name__)
else:
import pkg_resources
__version__ = VERSION = pkg_resources.get_distribution(__name__).version


__all__ = [
Expand Down

0 comments on commit cdf0328

Please sign in to comment.