Skip to main content

Profile the import time of a module.

Project description

importfiler

Profile your imports, find what is dragging your module load time.

importfiler builds on top of the output generated by the interpreter -X importtime traces. It is just a different output targeted more at a specific use-case. Finding what modules impact the longest on a specific one you are trying to optimize.

If you need a more detailed result, check out py-spy or any other runtime profiler.

Getting dependencies import time

Given an import, shows the the time spent importing direct dependencies. The import time does include the time spent on importing other modules.

This helps you finding the most time consuming imports in your library/app.

Examples:

$ python -m importfiler requests
modules:            time(%)
------------------- --------
requests            100 %
urllib3             61 %
charset_normalizer  11 %
http.cookiejar      10 %
idna                2 %
certifi             2 %
http.cookies        1 %
zipfile             1 %

Getting the time in milliseconds:

$ python -m importfiler --unit=ms requests
modules:            time(ms)
------------------- ---------
requests            48 ms
urllib3             29 ms
charset_normalizer  5 ms
http.cookiejar      4 ms
idna                1 ms
certifi             1 ms

Getting all_modules import time

Given an import, shows the the time spent loading all its dependencies (including transitive). The import time does not include the time spent on importing other modules.

This helps you finding the most time consuming modules across your chain of dependencies.

Examples:

$ python -m importfiler --mode="all_modules" requests
modules:             time (%)             submodules
-------------------- -------------------- --------------------
urllib3              17 %                 urllib3.util.url, urllib3.packages.six, urllib3.exceptions, urllib3.poolmanager, ...
email                7 %                  email._policybase, email.message, email.header, email.feedparser, ...
charset_normalizer   6 %                  charset_normalizer.constant, charset_normalizer.models, charset_normalizer.cd, ...
requests             6 %                  requests.utils, requests.models, requests.exceptions, requests.packages, ...
http                 6 %                  http.cookiejar, http.client, http.cookies
urllib               4 %                  urllib.request, urllib.parse, urllib.error, urllib.response
typing               3 %
ssl                  2 %
importlib            2 %                  importlib.resources._adapters, importlib.resources.abc, importlib.resources._common, ...
re                   2 %                  re._parser, re._compiler, re._constants, re._casefix

Getting the time in milliseconds:

$ python -m importfiler --mode="all_modules" --unit=ms requests
modules:             time (ms)            submodules
-------------------- -------------------- --------------------
urllib3              18 ms                urllib3.util.url, urllib3.packages.six, urllib3.exceptions, urllib3.connectionpool, ...
charset_normalizer   8 ms                 charset_normalizer.md__mypyc, charset_normalizer.constant, charset_normalizer.models, ...
requests             7 ms                 requests.utils, requests.exceptions, requests.models, requests.packages, ...
email                3 ms                 email._policybase, email.header, email.feedparser, email.utils, ...
http                 3 ms                 http.cookiejar, http.cookies, http.client
idna                 2 ms                 idna.core, idna.idnadata, idna.package_data, idna.intranges
urllib               1 ms                 urllib.request, urllib.parse, urllib.error, urllib.response
importlib            1 ms                 importlib.resources._adapters, importlib.resources.abc, importlib.resources._common, ...
typing               1 ms
ssl                  1 ms
re                   1 ms                 re._parser, re._compiler, re._constants, re._casefix

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

importfiler-0.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

importfiler-0.0.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file importfiler-0.0.2.tar.gz.

File metadata

  • Download URL: importfiler-0.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4+

File hashes

Hashes for importfiler-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1190c4a981fd4d82ae76439f45fda9d643b3ada7862cea3220b3d11be987676b
MD5 31d7b1aebdc2531f32429c2a2cf47a16
BLAKE2b-256 d2c4bd0d993bb1880b3ce6162ba0f7061279c9d236de2fdd6091b7cd42ec62c8

See more details on using hashes here.

File details

Details for the file importfiler-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: importfiler-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4+

File hashes

Hashes for importfiler-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b0d4a16c1b3b6b5b3d492e6fe82b7714f5dc4a6a484e9817d322b54d1e2ee80
MD5 81b3eb02e982affeb43aaace9e8fcd0a
BLAKE2b-256 992de4942005b280b55bd02e9a65b5a2ffa059eb0a16e73f1c81b6239359ddb9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page