line_profiler is a Python profiling tool that performs line-by-line analysis of function execution time.
The tool addresses the problem of identifying performance bottlenecks within slow functions. When function-level profiling reveals a slow function, developers need visibility into which individual source lines consume the most time. line_profiler solves this by instrumenting functions with the @profile decorator and measuring execution time at the line level. The kernprof command-line utility included with the package orchestrates the profiling process. The recommended workflow involves importing profile, decorating target functions, and running the script with the LINE_PROFILE environment variable set to enable profiling output.
Developers should choose this tool when they have already identified a slow function through higher-level profiling and need to drill down to the source line responsible for the performance issue. It suits any Python project where understanding fine-grained execution time distribution is necessary for optimization. The tool maintains backward compatibility with the older kernprof command-line workflow for users accustomed to that interface, though the environment variable approach is now the primary recommended method.
The project is actively maintained as the official continuation of an earlier unmaintained package. Development includes regular updates to support current Python versions, with wheels published for common platforms to minimize installation friction. The codebase maintains comprehensive documentation covering basic usage, examples, and frequently asked questions, alongside an active issue tracker for bug reports and feature requests.