Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add-X importtime=2 for additional logging when an imported module is already loaded #102567

Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement
@noahbkim

Description

@noahbkim

Feature or enhancement

Add special handling for-X importtime=2 that provides additional output when already-loaded modules are imported. This will allow users to get a complete picture of runtime imports.

Pitch

While-X importtime is incredibly useful for analyzing module import times, by design, it doesn't log anything if an imported module has already been loaded.-X importtime=2 would provide additional output for every module that's already been loaded:

>>> import uuidimport time: cached    | cached     |   _ioimport time: cached    | cached     |   _ioimport time: cached    | cached     |   osimport time: cached    | cached     |   sysimport time: cached    | cached     |   enumimport time: cached    | cached     |     _ioimport time: cached    | cached     |     _ioimport time: cached    | cached     |     collectionsimport time: cached    | cached     |     osimport time: cached    | cached     |     reimport time: cached    | cached     |     sysimport time: cached    | cached     |     functoolsimport time: cached    | cached     |     itertoolsimport time:       151 |        151 |     _wmiimport time:     18290 |      18440 |   platformimport time:       372 |        372 |   _uuidimport time:     10955 |      29766 | uuid

In codebases with convoluted/poorly managed import graphs (and consequently, workloads that suffer from long import times), the ability to record all paths to an expensive dependency–not just the first-imported–can help expedite refactoring (and help scale identification of this type of issue). More generally, this flag would provide a more efficient path to tracking runtime dependencies.

The changes required are largely unintrusive: here's my reference implementation: [will relink, need to do some paperwork].

Previous discussion

Discussion:https://discuss.python.org/t/x-importtrace-to-supplement-x-importtime-for-loaded-modules/23882/5
Prior email chain:https://mail.python.org/archives/list/python-ideas@python.org/thread/GEISYQ5BXWGKT33RWF77EOSOMMMFUBUS/

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp