📜 Overview
| General Information | |
|---|---|
| Repository | |
| Build | |
| Code |
💡 Introduction
LineScope shows where time is spent in your Python source, line by line. Browse full files and notebook cells, follow function and class links, and inspect Spark executions beside the driver code that triggered them. Work inside pandas, native libraries, I/O, and other dependencies stays attributed to the relevant source line instead of filling the report with their internals.
The result is a single HTML file with its own source snapshots, styles, and scripts. Open it offline, revisit it after code changes, or share it after reviewing the embedded source.
❗ Why use LineScope?
- Source first. Full files and cells, timing heatmaps, and unexecuted lines in context.
- Follow your code. Click individual function, class, and resolved method calls.
- Several ways to work. Context managers, explicit start/stop, CLI scripts/modules, and cell magic.
- Spark aware. Observe real actions and available executed plans without forcing lazy work.
- Honest measurements. Keep missing metrics unknown and driver time separate from executor work.
- Portable reports. No server or CDN needed to view the generated HTML.
- Pluggable collection. Choose from 3 different profiling backends: trace, scalene or trachyon.
🚀 Getting started
Installation
Install or upgrade LineScope in the same environment as your script or notebook. Python 3.11–3.15 is supported:
uv pip install --upgrade linescope
Use an existing virtual environment, or create one with uv venv first.
Activate it with .venv\Scripts\Activate.ps1 in PowerShell or
source .venv/bin/activate on Linux and macOS. With pip, use
python -m pip install --upgrade linescope; you can replace uv pip with
python -m pip in the commands below.
The base package includes the default Trace profiler, CLI, HTML reports, and driver memory collection.
Latest source
Install unreleased changes directly from the main branch. Git is required:
uv pip install --upgrade "git+https://github.com/tvdboom/linescope.git@main"
Optional dependencies
-
scaleneinstalls Scalene for CPU sampling and supported GPU measurements on Python 3.11–3.14. Select it with--backend scaleneorbackend="scalene"; it is omitted on Python 3.15.uv pip install --upgrade "linescope[scalene]" -
notebookinstalls IPython and ipykernel for cell magics, notebook capture, and inline reports.uv pip install --upgrade "linescope[notebook]" -
fullinstalls both extras. Scalene is omitted on Python 3.15; development tools and GPU demo dependencies are separate.uv pip install --upgrade "linescope[full]"
Combine individual extras with linescope[scalene,notebook]. Spark and
Databricks integration use the runtime's existing PySpark and Databricks SDK;
LineScope does not install either library. Install the base package or
linescope[notebook] in those environments. Spark profiling is opt-in with
spark=True or --spark, and requires PySpark to be available.
Install the latest source with all integrations directly from Git:
uv pip install "linescope[full] @ git+https://github.com/tvdboom/linescope"
Contributing
Install the locked development environment from a checkout:
git clone https://github.com/tvdboom/linescope.git
cd linescope
uv sync --locked
See the installation guide for more setup details and the development guide for contribution checks.
Usage
From the terminal
Run your own script under LineScope without changing its source:
linescope --backend trace --output linescope.html your_script.py
The script runs normally, then LineScope saves linescope.html in the current
directory and opens it in a browser. The report contains your source with
line-by-line timings and works offline.
Place LineScope options before the script path. Arguments after the path go to your script. You can also profile an importable module from your project root:
linescope --backend trace --output linescope.html your_script.py --input data.csv
linescope --backend trace --output linescope.html -m your_package.your_module
To save the report without opening a browser:
linescope --backend trace --display none --output linescope.html your_script.py
From Python code
Wrap the work you want to measure with profile in your own script. Here,
main() is your existing entry point; replace it with the calls you want to
profile:
from linescope import profile
with profile(backend="trace", output="linescope.html") as session:
main()
Run the script as usual:
python your_script.py
When the block exits, profiling stops and the report is saved and opened. For
headless use, add display="none" to profile(...) and call
session.save("linescope.html") after the block to write the report.
📘 Documentation
| Relevant links | |
|---|---|
| ⭐ About | Learn more about the package. |
| 🚀 Getting started | New to LineScope? Here's how to get you started! |
| 👨💻 User guide | How to use LineScope and its features. |
| 📓 Notebooks | Profile a cell or a whole notebook session. |
| ⚡ Spark | Follow Spark actions, executed plans, and distributed metrics. |
| 🧱 Databricks | Capture workspace source and correlate child notebook runs. |
| 🎛️ API Reference | The detailed reference for LineScope's API. |
| ⌨️ CLI | Profile Python scripts and modules from the command line. |
| ❔ FAQ | Get answers to frequently asked questions. |
| 🔧 Contributing | Read this before creating a PR. |
| 🌳 Dependencies | Which other packages does LineScope depend on? |
| 📃 License | Copyright and permissions under the MIT license. |
Metadata
Release files for linescope 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| linescope-0.1.0.tar.gz | 4.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linescope-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.8 MB
Release files / linescope-0.1.0.tar.gz
| Download URL | linescope-0.1.0.tar.gz |
|---|---|
| Size | 4.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efc43b541c143f3121880d845e1afd6fdc34b679fb94a2eaadbf55586c959e3f
|
|
BLAKE2b-256 checksum How to use checksums |
bddd9c8cffc78c2bb1bcfea67fb1fc15d823e91ece50aef414a8464bf916840c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / linescope-0.1.0-py3-none-any.whl
| Download URL | linescope-0.1.0-py3-none-any.whl |
|---|---|
| Size | 496.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b13b4ab311af5b6eb0dd8e016ca57efc5e0b9a9d9de3195eeff61d8417fe13be
|
|
BLAKE2b-256 checksum How to use checksums |
32d1c998dd125ccd214e6bd7387e79e12278420b9136c20630c97ce60e91a227
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|