Skip to main content

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

Metadata

Release files for importfiler 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for importfiler 0.0.2
File Size Uploaded Provenance
importfiler-0.0.2.tar.gz 5.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for importfiler 0.0.2
File Interpreter ABI Platform
importfiler-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / importfiler-0.0.2.tar.gz

Download URL importfiler-0.0.2.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1190c4a981fd4d82ae76439f45fda9d643b3ada7862cea3220b3d11be987676b
BLAKE2b-256 checksum
How to use checksums
d2c4bd0d993bb1880b3ce6162ba0f7061279c9d236de2fdd6091b7cd42ec62c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4+

Release files / importfiler-0.0.2-py3-none-any.whl

Download URL importfiler-0.0.2-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b0d4a16c1b3b6b5b3d492e6fe82b7714f5dc4a6a484e9817d322b54d1e2ee80
BLAKE2b-256 checksum
How to use checksums
992de4942005b280b55bd02e9a65b5a2ffa059eb0a16e73f1c81b6239359ddb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.4+

Security for importfiler 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page