Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>PyImport CostNew to Visual Studio Code? Get it now.
PyImport Cost

PyImport Cost

alkhemrt

|
3 installs
| (0) | Free
Display the disk size and import time of Python packages inline
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Python Import Cost

Displays the disk size and import time of every Python package inline in the editor — right next to the import statement, as you type.

Inspired by the original Import Cost extension for JavaScript.

How it works

The extension scans your file for import statements and runs two lightweight checks per package:

  • Disk size — resolved via importlib.metadata, the same mechanism pip uses internally.
  • Import time — measured with python -X importtime, capturing cold-start latency.

Results are colour-coded and displayed as inline ghost text. Everything is cached per package and per interpreter, so the editor stays fast after the first analysis.

Requirements

  • Python 3.8+
  • The Python extension is recommended for accurate interpreter and virtualenv detection, but not required.

Settings

Setting Default Description
pythonImportCost.showSize true Show disk size inline
pythonImportCost.showImportTime true Show import time inline
pythonImportCost.sizeWarningThresholdKb 1024 KB threshold for medium (yellow)
pythonImportCost.sizeDangerThresholdKb 5120 KB threshold for large (red)
pythonImportCost.timeWarningThresholdMs 100 ms threshold for medium (yellow)
pythonImportCost.timeDangerThresholdMs 500 ms threshold for large (red)
pythonImportCost.debounceMs 500 Delay after last keystroke before analysis runs
pythonImportCost.cacheSize 200 Max cached results held in memory

Colours can be overridden in your theme via the pythonImportCost.small, pythonImportCost.medium, and pythonImportCost.large colour contributions.

Commands

Python Import Cost: Clear Cache — forces a fresh analysis on the active file.

Contributing

$ git clone https://github.com/Alkhemrt/python-import-cost.git
$ cd python-import-cost
$ npm install
$ code .

Hit F5 to launch the extension in a VS Code Extension Development Host.

$ npm run compile   # one-off build
$ npm run watch     # watch mode
$ npm run lint      # lint
$ vsce package      # produce .vsix

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft