pypi / line-profiler
line-profiler
What changed in line-profiler 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
4 breaking10 new APIs and options2 performance6 behavior and defaults17 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initline-profiler 535 changes
Breaking changes 3
Text output no longer defaults to alphabetical ordering of profiled functions.
Controls verbosity level, allowing diagnostic outputs or output suppression.
Controls verbosity level rather than acting as a boolean.
New APIs and options 9
LineStats aggregation is added, allowing line statistics to be aggregated.
Adds an IPython magic function for profiling with %%lprun_all.
Run and profile module, package, or inline-script execution instead of a script file.
Can now be used as a class decorator.
Run and profile a library module as a script.
Restore the previous behavior where -p targets are not imported and profiled unless directly imported by the run target.
A [tool.line_profiler.kernprof] section can set kernprof defaults, including line-by-line, rich, verbose, skip-zero, and prof-mod.
Configure defaults for CLI options, GlobalProfiler, and profiler output formatting in pyproject.toml.
Specify modules or dotted function names to profile automatically, without requiring the @profile decorator.
Performance 1
Worst-case overhead is reduced, improving performance when profiling.
Behavior and default changes 6
Using '-' as the script-file name reads from and profiles stdin.
Multiple profiler instances can be used simultaneously.
Auto-profile top-level callables from imported targets; targets can be supplied across multiple -p flags.
On Python 3.11 and later, profiled objects are reported using their qualified names.
LineProfiler caches existing sys or sys.monitoring trace callbacks when enabled and restores them when disabled, rather than discarding them.
Profiling uses sys.monitoring on Python 3.12 and later, with fallback support; the legacy trace system can also be selected through an environment variable.
Fixes and other changes 16
Decorating a function no longer destroys its type.
Handling of multi-target from-import statements was fixed.
kernprof now always runs code in sys.modules['__main__']'s namespace.
Running kernprof.main no longer reverts the entirety of sys.modules.
Bytecode for profiled functions is always padded.
Recursive calls are now counted correctly.
The typing of ScopingPolicy members was fixed.
Unencodable characters are escaped instead of causing lines to be dropped.
A type fix was made to the base; the notes do not specify further details.
File resolution for files executed with kernprof -m now uses the import system.
Fixes and build changes improve compatibility with Python 3.14, including preventing duplicate output.
Reference-count leaks are fixed.
Profiling support is improved for class methods, static and bound methods, partial methods and objects, cached properties, and async generator functions.
Cleanup code now runs when exceptions occur inside the context.
Line tracing for Cython code is fixed.
Now includes profiling data from duplicate code objects.
line-profiler 44 changes
Breaking changes 1
The attribute is now indexed by a hash of the code block's bytecode and its line number; code that directly reads, processes, or edits it will likely break.
New APIs and options 1
Adds an option to output profiling data to the output file every n seconds, useful for long-running tasks that should not be stopped during processing.
Performance 1
Profiling overhead is drastically smaller, with reductions of 0.3 to 1 microseconds per line hit and speedups of up to 4x for some codebases.
Fixes and other changes 1
Python 3.11 is now supported.