pyImportCost
A Visual Studio Code extension that displays the size of Python imports in real-time.
Preview

Features
- Real-time Size Display: Shows import package sizes next to import statements in Python files
- Smart Package Classification: Automatically identifies standard library, third-party, and local modules
- Color-coded Visual Indicators: Uses different colors based on package size thresholds
- Hover Information: Displays detailed package information including type, size, and repository links
- Configurable Size Thresholds: Customizable size levels with corresponding color labels
- Standard Library Control: Option to show/hide standard library module sizes
- Repository Links: Clickable links to package repositories in hover tooltips
Requirements
- Visual Studio Code 1.85.1 or higher
- Python environment (automatically detects the active Python interpreter)
Installation
- Open Visual Studio Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "pyImportCost"
- Click Install
Extension Settings
This extension contributes the following configuration options:
Display Settings
pythonImportCost.display.showStdLib: Show size indicator for Python Standard Library (default: true)
pythonImportCost.display.showUrlInLine: Display repository URL text at the end of the line (default: false)
Color Settings
pythonImportCost.colors.stdlib: Color for Built-in and Standard Library modules (default: #888888)
Size Levels Configuration
pythonImportCost.levels: Define size thresholds and colors (order implies priority from top to bottom)
- Default configuration:
[
{ "max": 50, "color": "#7cc36e", "label": "Small (<50KB)" },
{ "max": 2048, "color": "#cfa344", "label": "Medium (<2MB)" },
{ "max": null, "color": "#d44e40", "label": "Large (>2MB)" }
]
Python Path Settings
pythonImportCost.pythonPath: Manually specify Python executable path (optional, uses active environment if empty)
Usage
- Open any Python file (.py)
- The extension automatically activates and displays package sizes next to import statements
- Hover over any import statement to see detailed information
- Click repository links in hover tooltips to open package repositories
Example
import numpy # Displays size information here
from sklearn import datasets # And here too
Package Types
The extension classifies packages into four types:
- Built-in: Core Python built-in modules
- Standard Library: Python standard library modules
- Third-party: External packages installed via pip/conda
- Local: Local project modules
Known Issues
- Initial loading may take some time to fetch package size information
- Some private or custom-installed packages may not be properly recognized
- Network connectivity issues may affect package information retrieval
- Large projects with many imports may experience slight performance impact
Release Notes
0.0.3
Initial release with:
- Basic package size display functionality
- Smart package type recognition
- Configurable color and threshold settings
- Hover information display
- Repository link integration
0.0.4
0.0.5
- add images to readme.md
- fix some typos
- add license.md
- add comments
Enjoy using pyImportCost!
| |