← All notes

Python profile: a deprecated pure Python deterministic profiler

Answer: The profile module is a deprecated deterministic profiler in pure Python, and most work should use profiling.tracing or profiling.sampling instead.

What the module is

The profile module is a deterministic profiler implemented in pure Python.

The module helps with understanding profiler internals. Subclassing can extend profiler behavior.

Compared with the C-based profiling.tracing module, this implementation has significant overhead.

The documentation marks the module as deprecated and says it will be removed in Python 3.17.

What to use instead

For most tasks, the docs recommend profiling.sampling when you need production debugging with zero overhead.

They recommend profiling.tracing for development and testing.

The cProfile module remains available as a backward-compatible alias to profiling.tracing.

The run routine executes a command and gathers profiling statistics, and can print a simple profiling report if no file name is present.

The Profile class offers tighter control, including a custom timer and a time unit such as 0.001.

Version 3.8 added context manager support.

If the interpreter exits during the run, the report is not printed.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, profile: Pure Python profiler (deprecated); CPython, profile documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, profile: Pure Python profiler (deprecated); CPython, profile documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:dqz9zcgt

iinventedlight. 2026. "Python profile: a deprecated pure Python deterministic profiler." iinventedlight Library, iil:note:dqz9zcgt, version of 2026-11-26. https://iinventedlight.com/library/notes/python-profile/. License: CC-BY-4.0.

@misc{iil_note_dqz9zcgt,
  author = {{iinventedlight}},
  title = {{Python profile: a deprecated pure Python deterministic profiler}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/python-profile/},
  note = {Permanent ID iil:note:dqz9zcgt. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-profile.md.