Releases: pyutils/line_profiler
Version 5.0.0
This is a major update to the line-profiler package. All APIs should still be backwards compatible with the 4.x branch, but we decided to bump the the new major version 5.x due to the number of new features and changes in the underlying C code. We do plan to introduce changes in defaults in the next 6.x release in an effort to streamline usage.
Big thanks to @TTsangSC who put an enormous amount of work into this 🙏 .
Highlights
- New TOML configuration files: control defaults via
[tool.line_profiler]inpyproject.toml. See docs for an example. - Much better auto-profiling: use
-p <modname>orprof-modin config to profile top-level callables - New CLI modes: run modules with
-m, inline scripts with-c, and profile from stdin with- - Switched to
sys.monitoringon Python 3.12+ (with fallback support) - Improved support for profiling class methods, properties, async generators, and
functools.partial - Output now shows qualified names (Python ≥ 3.11)
- Multiple profiler instances can now be used at the same time
- Many other fixes and improvements
CHANGELOG
-
FIX: win32 encoding issues
-
ENH: Add support for
sys.monitoring(Python >= 3.12) -
FIX: Fixed issue when calling
kernprofwith neither the-lnor-bflag; also refactored common methods toLineProfilerandContextualProfile -
FIX: Fixed auto-profiling of async function definitions #330
-
ENH: Added CLI argument
-mtokernproffor running a library module as a script; also made it possible for profiling targets to be supplied across multiple-pflags -
FIX: Fixed explicit profiling of class methods; added handling for profiling static, bound, and partial methods,
functools.partialobjects, (cached) properties, and async generator functions -
FIX: Fixed namespace bug when running
kernprof -mon certain modules (e.g.calendaron Python 3.12+). -
FIX: Fixed
@contextlib.contextmanagerbug where the cleanup code (e.g. restoration ofsysattributes) is not run if exceptions occurred inside the context -
ENH: Added CLI arguments
-ctokernproffor (auto-)profiling module/package/inline-script execution instead of that of script files; passing'-'as the script-file name now also reads from and profilesstdin -
ENH: In Python >=3.11, profiled objects are reported using their qualified name.
-
ENH: Highlight final summary using rich if enabled
-
ENH: Made it possible to use multiple profiler instances simultaneously
-
ENH: various improvements related to auto-profiling:
kernprof -ptarget entities are now imported and profiled regardless of
whether they are directly imported in the run script/module/code (old
behavior restored by passing--no-preimports)kernprof -vand the new-qnow control the verbosity level instead
of being a boolean, allowing diagnostic outputs or output suppression- On-import profiling is now more aggressive so that it doesn't miss entities
like class methods and properties LineProfilercan now be used as a class decorator
-
FIX: Fixed line tracing for Cython code; superseded use of the legacy tracing system with
sys.monitoring -
FIX: Fixed edge cases where:
-
FIX: Tracing-system-related fixes (#333):
LineProfilernow caches the existingsysorsys.monitoringtrace
callbacks in.enable()and restores them in.disable(), instead of
always discarding them on the way out- Also added experimental support for calling (instead of suspending) said
callbacks during profiling - Now allowing switching back to the "legacy" trace system on Python 3.12+,
controlled by an environment variable
-
ENH: Added capability to parse TOML config files for defaults (#335):
kernprofandpython -m line_profilerCLI optionsGlobalProfilerconfigurations, and- profiler output (e.g.
LineProfiler.print_stats()) formatting
Merged PRs
- Dev/4.2.1 by @Erotemic in #308
- Splendid main by @Erotemic in #313
- fix: pypi download link in readme by @Erotemic in #314
- Updated StaticVisitor by @lczyk in #317
- CI Update by @Erotemic in #324
- FIX: auto-profile transformer typo by @TTsangSC in #325
- ENH:
sys.monitoringcompliance by @TTsangSC in #327 - FIX:
kernproferroring out in non--l, non--bmode in Python 3.12+ by @TTsangSC in #326 - floating point format %5.1g is too restrictives by @melnikovsky in #329
- Fix: auto-profiling
async defby @TTsangSC in #331 - ENH: auto-profile module execution by @TTsangSC in #323
- FIX: (+ENH?) fixed and extended dispatching for
LineProfiler.__call__()by @TTsangSC in #332 - doc: fix typo by @davidxia in #336
- FIX:
kernprof -m: presence of the executed module assys.modules['__main__']by @TTsangSC in #339 - FIX: fixed cleanup code in
@contextlib.contextmanagerby @TTsangSC in #340 - [RFC] Broaden support for profiling generated code by @matthiasdiener in #341
- ENH: auto-profile
stdinor literal snippets by @TTsangSC in #338 - test that generated code displays source code in profile by @matthiasdiener in #343
- Prevent encoding error in IPython extension in Windows by @vnmabus in #342
- Highlight line profiler summary using rich by @Erotemic in #346
- Use co_qualname in reporting when possible by @Erotemic in #345
- ENH: use multiple profiler instances by @TTsangSC in #347
- ENH: more intuitive profiling-target selection by @TTsangSC in #337
- Post-337 patches: docs, fixes, minor refactoring by @TTsangSC in #353
- FIX: debug-mode and logging bugs in #337 by @TTsangSC in #354
- FIX: restore Cython compatibility + pivot to
sys.monitoringby @TTsangSC in #352 - FIX:
LineProfiler.last_timealways empty (and sometimes errors out) by @TTsangSC in #344 - FIX: Update hash tables of affected profiler instances when rewriting code objects by @TTsangSC in #351
- FIX: aggregating profiling data from duplicate code objects by @TTsangSC in #349
- FIX: missing line events for
raisestatements andfinally: ...bodies in Python 3.12+ by @TTsangSC in #356 - Restore trace callback when the profiler is disabled by @TTsangSC in #334
- ENH: read TOML files for configurations by @TTsangSC in #335
- Dev/prep 5x release by @Erotemic in #363
New Contributors
- @lczyk made their first contribution in #317
- @melnikovsky made their first contribution in #329
- @davidxia made their first contribution in #336
- @matthiasdiener made their first contribution in #341
- @vnmabus made their first contribution in #342
Full Changelog: v4.2.0...refs/heads/release
Version 4.2.0
Automatic Release Notes.
What's Changed
- Added support for annotated assignments in the static parser by @TTsangSC in #280
- Development Branch for 4.1.4 by @Erotemic in #265
- Remove 36 and 37 support by @Erotemic in #288
- Fix noop code by @Erotemic in #286
- Update docs by @Erotemic in #285
- Support 313 by @Erotemic in #287
- Rotate secrets by @Erotemic in #294
- Add unit example by @Erotemic in #293
- Official 3.13 on CI by @Erotemic in #297
New Contributors
Full Changelog: v4.1.3...refs/heads/release
Version 4.1.3
Version 4.1.3
- FIX: duration summary now respects the stripzeros argument.
- FIX: minor test fixes.
- ENH: building osx wheels for x86 and arm64.
- ENH: documentation improvements.
- ENH: signed wheels are now hosted on github and published as release artifacts.
What's Changed
- Invoke subshell with the current python interpreter by @dirkmueller in #252
- Maintenance Branch Dev/4.1.3 by @Erotemic in #257
- Add modern quickstart instructions to README by @Erotemic in #259
- Respect stripzeros in summary report by @Erotemic in #260
- Ensure x86 and arm64 wheels are built for osx by @Erotemic in #263
- Normalize path before comparison @amirebrahimi in #264
New Contributors
- @dirkmueller made their first contribution in #252
- @amirebrahimi made their first contribution in #264
Full Changelog: v4.1.2...refs/heads/release
Version 4.1.2
Version 4.1.1
4.1.1
* FIX: ``get_stats`` is no longer slowed down when profiling many code sections #236
Thanks @klauer
Version 4.1.0
This new version contains big quality of life improvements.
Highlights
Documentation: We now have readthedocs documentation that covers usage tutorials and the API.
Explicit Decorator: There is now a global profile decorator. In your code import line_profiler and decorate functions with @line_profiler.profile. Your code runs as normal by default. Setting the environment variable LINE_PROFILE=1 will enable profiling. For details see the docs.
Auto-Profiling: Users can now run kernprof with -p <modname> to profile all functions in a module without explicitly decorating them. For details see the docs.
CHANGELOG
- FIX: skipzeros now checks for zero hits instead of zero time
- FIX: Fixed errors in Python 3.11 with duplicate functions.
- FIX:
show_textnow increases column sizes or switches to scientific notation to maintain alignment - ENH:
show_textnow has new options: sort and summarize - ENH: Added new CLI arguments
-srmtoline_profilerto control sorting, rich printing, and summary printing. - ENH: New global
profilefunction that can be enabled by--profileorLINE_PROFILE=1. - ENH: New auto-profile feature in
kernprofthat will profile all functions in specified modules. - ENH: Kernprof now outputs instructions on how to view results.
- ENH: Added readthedocs integration: https://kernprof.readthedocs.io/en/latest/index.html
Version 4.0.3
4.0.3
* FIX: Stop requiring bleeding-edge Cython unless necesasry (for Python 3.12). #206
Version 4.0.2
- FIX: AttributeError on certain methods. #191
Version 4.0.1
- FIX: Profiling classmethods works again. #183
Version 4.0.0
- ENH: Python 3.11 is now supported.
- ENH: Profiling overhead is now drastically smaller, thanks to reimplementing almost all of the tracing callback in C++. You can expect to see reductions of between 0.3 and 1 microseconds per line hit, resulting in a speedup of up to 4x for codebases with many lines of Python that only do a little work per line.
- ENH: Added the
-i <# of seconds>option to thekernprofscript. This uses the threading module to output profiling data to the output file every n seconds, and is useful for long-running tasks that shouldn't be stopped in the middle of processing. - CHANGE: Cython's native cythonize function is now used to compile the project, instead of scikit-build's convoluted process.
- CHANGE: Due to optimizations done while reimplementing the callback in C++, the profiler's code_map and last_time attributes now are indexed by a hash of the code block's bytecode and its line number. Any code that directly reads (and processes) or edits the code_map and/or last_time attributes will likely break.
Thanks to @Theelx and others for all of their hard work on this!