line-profiler
Line-by-line profiler
Decision gist · record as of 2026-08-14
Yes. line_profiler is actively maintained, has no known vulnerabilities, runs on modern Python versions (3.8–3.14), and solves a real problem that standard profilers do not: identifying slow individual statements. Install friction is moderate but manageable via prebuilt wheels. The BSD license imposes no restrictions. It is a standard tool in the Python performance-debugging toolkit.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- C compiler required when building from source; prebuilt wheels avoid this for standard Python versions on common platforms.
- Medium install friction due to C extension compilation, but prebuilt wheels are available for Python 3.8–3.14 on major platforms (Linux, macOS, Windows).
- The package is actively maintained with a recent release and no known vulnerabilities.
License · maintenance · safety
BSD (permissive) — BSD license is permissive and places no significant restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2026-02-23 (172 days) · last repo commit 2026-08-14 · 3,241 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,069,356 downloads/mo, #2,768 on PyPI
Alternatives
Verify before relying
pip install line_profiler
import line_profiler
@line_profiler.profile
def my_function():
pass
# Set LINE_PROFILE=1 environment variable and run your script- Whether the package works with Python 3.13 and 3.14 in practice, given classifiers list them but the description's version history may predate their release.
What it is and what it does
line_profiler is a Python profiling module that measures execution time at the individual line level within decorated functions, complementing Python's standard cProfile which only times explicit function calls. This is particularly useful for identifying performance bottlenecks in scientific computing or data-heavy code where a single statement (like a NumPy array operation) can dominate runtime without appearing as a function call.
The package provides two main interfaces: the line_profiler module itself, which can be imported and used programmatically with the @line_profiler.profile decorator, and kernprof, a command-line script that automates profiling workflows. Modern versions (4.1.0+) support environment-variable-based activation via LINE_PROFILE=1, while legacy workflows use the kernprof command directly. Results are written to .lprof binary files and can be inspected via the command line or Python module.
Use it for
- Identify which lines in a NumPy-heavy function consume the most time when function-level profiling shows only a single call.
- Optimize data processing pipelines by pinpointing slow statements in tight loops that cProfile would not break down.
- Debug performance regressions in scientific computing code by comparing line-level timings before and after changes.
- Profile web request handlers or batch jobs to find unexpectedly slow operations within a single function.
- Validate algorithmic improvements by measuring per-line execution time changes in critical functions.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
line_profiler is actively maintained, has no known vulnerabilities, runs on modern Python versions (3.8–3.14), and solves a real problem that standard profilers do not: identifying slow individual statements. Install friction is moderate but manageable via prebuilt wheels. The BSD license imposes no restrictions. It is a standard tool in the Python performance-debugging toolkit.
Install
line-profiler on PyPI
Before you install
Medium install friction due to C extension compilation, but prebuilt wheels are available for Python 3.8–3.14 on major platforms (Linux, macOS, Windows). The package is actively maintained with a recent release and no known vulnerabilities.
C compiler required when building from source; prebuilt wheels avoid this for standard Python versions on common platforms.
License in practice
BSD license is permissive and places no significant restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install line_profiler
import line_profiler
@line_profiler.profile
def my_function():
pass
# Set LINE_PROFILE=1 environment variable and run your script
Verify before relying
- Whether the package works with Python 3.13 and 3.14 in practice, given classifiers list them but the description's version history may predate their release.
Package facts
| License | BSD permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 2 packagestomlityping_extensions |
| Maintenance | Actively maintained 172 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,069,356 / month, #2,768 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development |
Evidence: line_profiler-5.0.2-cp310-cp310-macosx_10_9_universal2.whl; line_profiler-5.0.2-cp310-cp310-macosx_10_9_x86_64.whl; line_profiler-5.0.2-cp310-cp310-macosx_11_0_arm64.whl; line_profiler-5.0.2-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; line_profiler-5.0.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; line_profiler-5.0.2-cp310-cp310-musllinux_1_2_aarch64.whl; line_profiler-5.0.2-cp310-cp310-musllinux_1_2_x86_64.whl; line_profiler-5.0.2-cp310-cp310-win_amd64.whl; line_profiler-5.0.2-cp311-cp311-macosx_10_9_universal2.whl; line_profiler-5.0.2-cp311-cp311-macosx_10_9_x86_64.whl; line_profiler-5.0.2-cp311-cp311-macosx_11_0_arm64.whl; line_profiler-5.0.2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; line_profiler-5.0.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; line_profiler-5.0.2-cp311-cp311-musllinux_1_2_aarch64.whl; line_profiler-5.0.2-cp311-cp311-musllinux_1_2_x86_64.whl; line_profiler-5.0.2-cp311-cp311-win_amd64.whl; line_profiler-5.0.2-cp311-cp311-win_arm64.whl; line_profiler-5.0.2-cp312-cp312-macosx_10_13_universal2.whl; line_profiler-5.0.2-cp312-cp312-macosx_10_13_x86_64.whl; line_profiler-5.0.2-cp312-cp312-macosx_11_0_arm64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “line by line profiling”
- line-profilerline_profiler measures execution time on a per-line basis within…
- NakedNaked is a command-line application framework that provides a CLI…
- scaleneScalene profiles Python code to measure CPU, GPU, and memory…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also ipython-autotime · memory-profiler · pyinstrument · yappi · scalene · pyprof2calltree · tuna · viztracer · django-cprofile-middleware · codetiming