Skip to content
Researched developer tool comparisonsPrices dated · vendor sources linked · no star ratings
Search

Stage 01 · Write · Researched comparison

Best Python Profilers for Real Workloads in 2026

cProfile is the default first pick because it ships with CPython and needs no install, which suits most developers starting to measure a slow script. py-spy is the better choice for profiling running processes and production code without changing them, and Scalene fits teams that want line-level detail on CPU, memory and GPU use with low overhead.

By
Published 22 Nov 2026 · 8 tools compared

We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.

Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.

Key takeaways

  • cProfile and profile are part of the Python standard library, so they are free and need no extra install.
  • py-spy samples running processes, including ones you did not start, and works without modifying code.
  • Scalene and line_profiler report per-line costs, which is more detail than cProfile gives by default.
  • Most of these tools are open source and run locally, so profiling data stays on your machine.

Who each pick is for

  • Quick whole-program profiling with no installcProfile
  • Sampling live and production processes without code changespy-spy
  • Line-level CPU, memory and GPU profiling with low overheadScalene
  • Timing individual lines inside chosen functionsline_profiler
  • Profiling multithreaded and asyncio codeYappi
  • Statistical profiling with flame graph outputAustin
  • Readable call-tree reports for web requests and scriptsPyinstrument
  • Tracking memory use per line and over timememory_profiler

Comparison

The 8 tools at a glance
ToolBest forStandout featureListed starting priceFree plan or trial
1cProfileQuick whole-program profiling with no installShips with CPythonFree (open source)Free plan
2py-spySampling live and production processes without code changesAttaches to running processesFree (open source)Free plan
3ScaleneLine-level CPU, memory and GPU profiling with low overheadReports CPU, memory and GPU use per lineFree (open source)Free plan
4line_profilerTiming individual lines inside chosen functionsPer-line timing with hit countsFree (open source)Free plan
5YappiProfiling multithreaded and asyncio codeHandles threads and coroutinesFree (open source)Free plan
6AustinStatistical profiling with flame graph outputLow-overhead samplingFree (open source)Free plan
7PyinstrumentReadable call-tree reports for web requests and scriptsClear tree outputFree (open source)Free plan
8memory_profilerTracking memory use per line and over timePer-line memory reportsFree (open source)Free plan

How we picked

We picked tools that do the profiling job named in each entry and are currently maintained, with a public repository or official documentation page. Criteria were fit for common profiling tasks, platform support, licence and price, whether data stays local, and known limits such as overhead or sampling error. Sources are vendor documentation, project repositories and public pricing pages. Prices and features change, so confirm on the vendor site before you rely on them.

The tools, one by one

01

cProfile

Best for quick whole-program profiling with no install

Visit docs.python.org
cProfile homepage
cProfile homepage, captured Nov 2026

What it is and where it fits

cProfile is the standard library profiler. You run it as a module, for example `python -m cProfile -s cumtime script.py`, and it reports call counts, total time and cumulative time per function. Because it is part of CPython, there is nothing to install and it works on any platform that runs Python. It is deterministic, so you see every call, not a sample.

The main cost is overhead. Instrumenting every call slows execution, which can distort results for very hot code. It also reports at the function level, so you often need a line profiler to find the exact statement. Use it first to find which functions dominate, then switch tools for detail. Skip it when you need to profile a process you cannot restart.

Standout: Ships with CPython

Pricing pointer

Free (open source), as listed by the vendor (cProfile website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Ships with CPython
  • deterministic per-function call counts and timings

Drawbacks

  • Adds overhead
  • reports function-level data, not line-level detail

Skip it if this limit matters to you: adds overhead.

Verdict. A sensible pick for quick whole-program profiling with no install.

Alternatives in this guide: py-spy, Scalene, line_profiler

02

py-spy

Best for sampling live and production processes without code changes

Visit github.com
py-spy homepage
py-spy homepage, captured Nov 2026

What it is and where it fits

py-spy is a sampling profiler written in Rust. It attaches to a running Python process by PID and records stack samples, so you do not need to modify or restart the code. It can produce flame graphs and a top-like live view. It runs on Linux, macOS and Windows, and it can profile processes in containers when permissions allow.

Because it samples rather than instruments, overhead is low and it is suitable for code that is already running, including in staging. The tradeoff is that very short calls may be missed. Attaching to another user's process needs the right permissions, and some hardened environments block it. Skip it if you need exact call counts rather than a statistical picture.

Standout: Attaches to running processes

Pricing pointer

Free (open source), as listed by the vendor (py-spy website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Attaches to running processes
  • low overhead sampling

Drawbacks

  • Sampling misses short calls
  • needs permissions to inspect other processes

Skip it if this limit matters to you: sampling misses short calls.

Verdict. A sensible pick for sampling live and production processes without code changes.

Alternatives in this guide: cProfile, Scalene, line_profiler

03

Scalene

Best for line-level CPU, memory and GPU profiling with low overhead

Visit github.com
Scalene homepage
Scalene homepage, captured Nov 2026

What it is and where it fits

Scalene is a profiler from the University of Massachusetts Amherst that combines sampling with instrumentation. It reports CPU time split between Python and native code, memory allocation per line, and GPU time where supported. It can run as a command-line tool or in a browser view, and it aims to keep overhead low enough for longer runs.

It runs on Linux, macOS and Windows, though some features are more complete on Linux and macOS. It is open source under the Apache 2.0 licence. It is a good fit when memory growth or native code is part of the problem, which cProfile does not show well. Skip it if you only need a quick function-level timing on a small script.

Standout: Reports CPU, memory and GPU use per line

Pricing pointer

Free (open source), as listed by the vendor (Scalene website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Reports CPU, memory and GPU use per line
  • low overhead sampling

Drawbacks

  • Best support on Linux and macOS
  • some features vary by platform

Skip it if this limit matters to you: best support on Linux and macOS.

Verdict. A sensible pick for line-level CPU, memory and GPU profiling with low overhead.

Alternatives in this guide: cProfile, py-spy, line_profiler

04

line_profiler

Best for timing individual lines inside chosen functions

Visit github.com
line_profiler homepage
line_profiler homepage, captured Nov 2026

What it is and where it fits

line_profiler times each line of functions you decorate with `@profile`. It reports hits, time per hit and percentage of total time per line, which makes it useful once cProfile has pointed you at a slow function. It runs on the major platforms and installs from PyPI. The `kernprof` script runs your code and prints the report.

The scope is narrow by design: only decorated functions are measured, and the overhead per line is higher than whole-program sampling. That makes it a second-step tool, not a first pass. It is open source and maintained under the pyutils organization. Skip it for memory questions, since it measures time only.

Standout: Per-line timing with hit counts

Pricing pointer

Free (open source), as listed by the vendor (line_profiler website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Per-line timing with hit counts
  • decorator marks functions to profile

Drawbacks

  • Only profiles marked functions
  • adds noticeable overhead

Skip it if this limit matters to you: only profiles marked functions.

Verdict. A sensible pick for timing individual lines inside chosen functions.

Alternatives in this guide: cProfile, py-spy, Scalene

05

Yappi

Best for profiling multithreaded and asyncio code

Visit github.com
Yappi homepage
Yappi homepage, captured Nov 2026

What it is and where it fits

Yappi is a pure-Python profiler that tracks threads and coroutines, which cProfile does not separate well. It offers wall-clock, CPU and other clock types, and it can profile code started after it is enabled. It is useful when a program is slow because of thread contention or async scheduling rather than a single hot function.

It installs from PyPI and runs on the standard platforms. It is open source. The API is less familiar than the standard library profiler, so expect some reading before the first run. Overhead depends on the clock and mode you choose. Skip it for simple single-threaded scripts where cProfile is enough.

Standout: Handles threads and coroutines

Pricing pointer

Free (open source), as listed by the vendor (Yappi website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Handles threads and coroutines
  • several clock types

Drawbacks

  • Smaller community than cProfile
  • API takes some learning

Skip it if this limit matters to you: smaller community than cProfile.

Verdict. A sensible pick for profiling multithreaded and asyncio code.

Alternatives in this guide: cProfile, py-spy, Scalene

06

Austin

Best for statistical profiling with flame graph output

Visit github.com
Austin homepage
Austin homepage, captured Nov 2026

What it is and where it fits

Austin is a frame stack sampler for CPython. It samples the interpreter's stack and writes data in formats such as collapsed stacks and speedscope, which you can open in flame graph tools. It runs on Linux, macOS and Windows, and it can attach to a running process. Because it samples, overhead is low and it suits longer runs.

It is a standalone binary rather than a pip package, so installation differs from the pure-Python tools. Results are statistical, so short calls can be missed. It is open source. It fits developers who already read flame graphs and want a lightweight sampler. Skip it if you need exact call counts or line-level memory data.

Standout: Low-overhead sampling

Pricing pointer

Free (open source), as listed by the vendor (Austin website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Low-overhead sampling
  • exports to common flame graph formats

Drawbacks

  • Statistical results, not exact counts
  • separate binary to install

Skip it if this limit matters to you: statistical results, not exact counts.

Verdict. A sensible pick for statistical profiling with flame graph output.

Alternatives in this guide: cProfile, py-spy, Scalene

07

Pyinstrument

Best for readable call-tree reports for web requests and scripts

Visit github.com
Pyinstrument homepage
Pyinstrument homepage, captured Nov 2026

What it is and where it fits

Pyinstrument is a statistical profiler that produces a call tree rather than a flat table. It can run as a command, as a magic in IPython, or as middleware in web frameworks to profile individual requests. It records wall-clock time, which matches what users feel, and it can hide library frames so your own code stands out.

It installs from PyPI and runs on the major platforms. It is open source. Because it samples, very short functions may not appear. The tree view is easier to read than cProfile output for many people, but deep stacks can still be noisy. Skip it if you need exact per-call counts or memory tracking.

Standout: Clear tree output

Pricing pointer

Free (open source), as listed by the vendor (Pyinstrument website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Clear tree output
  • can profile and render in a browser

Drawbacks

  • Sampling based
  • deep call stacks can be hard to read

Skip it if this limit matters to you: sampling based.

Verdict. A sensible pick for readable call-tree reports for web requests and scripts.

Alternatives in this guide: cProfile, py-spy, Scalene

08

memory_profiler

Best for tracking memory use per line and over time

Visit github.com
memory_profiler homepage
memory_profiler homepage, captured Nov 2026

What it is and where it fits

memory_profiler measures memory use rather than time. It decorates functions to report memory per line, and it can log a process's memory over time with `mprof`. It installs from PyPI and runs on the major platforms. It complements a CPU profiler when the problem is growth or a spike rather than slow code.

It adds noticeable overhead, so it is not for production runs. Reported numbers can differ between platforms and allocators, so treat them as relative. It is open source. Use it after a CPU profiler has shown that memory, not time, is the issue. Skip it if you only need timing data.

Standout: Per-line memory reports

Pricing pointer

Free (open source), as listed by the vendor (memory_profiler website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Per-line memory reports
  • can log memory over time

Drawbacks

  • Slower than CPU profilers
  • results vary by platform and allocator

Skip it if this limit matters to you: slower than CPU profilers.

Verdict. A sensible pick for tracking memory use per line and over time.

Alternatives in this guide: cProfile, py-spy, Scalene

Who should use what

If you are new to profiling a slow script, start with cProfile because it is already installed. If the process is already running in staging or production and you cannot restart it, use py-spy. If you suspect memory growth or want per-line detail, reach for Scalene or memory_profiler. If the code is multithreaded or async, Yappi separates threads and coroutines better than the standard profiler. For web request timing, Pyinstrument's request middleware gives a readable tree.

Questions to settle before you buy

What to check before you buy

  • Confirm the tool supports your Python version and operating system.
  • Check the overhead: sampling tools distort less than instrumenting ones.
  • Decide whether you need function-level, line-level or memory data.
  • Confirm you can attach to the process or restart it under the profiler.
  • Check the licence if you plan to use it inside a company or ship it.

FAQ

Is cProfile enough on its own?

For many small scripts, yes. It shows which functions take the most time and how often they are called. When you need line-level detail, memory data or profiling of a running process, add a second tool such as line_profiler, Scalene or py-spy.

Can I profile code in production?

Sampling profilers like py-spy and Austin are designed for low overhead and can attach to running processes. Even so, test in staging first, watch the impact, and check that permissions allow attaching. Instrumenting profilers add more overhead and are a poor fit for live traffic.

What is the difference between deterministic and sampling profilers?

Deterministic profilers such as cProfile record every call, so counts are exact but overhead is higher. Sampling profilers such as py-spy take periodic snapshots, so overhead is lower but very short calls can be missed. Use deterministic tools for accuracy and sampling tools for live or long runs.

Do these tools send my data anywhere?

The open-source tools listed here run locally and write reports to your machine or terminal. Check any browser-based viewer you use for flame graph output, and avoid uploading stack traces that contain secrets, tokens or customer data to third-party sites.

Which profiler handles asyncio and threads?

Yappi is built to separate threads and coroutines. py-spy can show what each thread is doing in its live view. cProfile reports aggregate function times and does not clearly separate concurrent work, so it is weaker for async and threaded programs.

Sources we checked

Method: how we score · editorial policy.

  1. cProfile (official site)
  2. py-spy (official site)
  3. Scalene (official site)
  4. line_profiler (official site)
  5. Yappi (official site)
  6. Austin (official site)
  7. Pyinstrument (official site)
  8. memory_profiler (official site)

Change log. First published 22 Nov 2026.