pypprof (version 0.0.1) adds HTTP-based endpoints to Python applications for collecting CPU and heap profiles, similar to Go's `net/http/pprof`. It leverages `zprofile` and `mprofile` under the hood for profile collection. The last release was in 2019, indicating the library is in a maintenance state rather than active development.
pip install pypprofVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `pypprof` into a simple Python application to expose profiling endpoints. After running, you can access CPU and heap profiles via `go tool pprof` (requires Go installed) or `curl` against the exposed `/debug/pprof/` endpoints. A background thread continuously performs a CPU-intensive task to generate data for profiling.
Evaluate alternative, actively maintained profiling libraries like `memory_profiler`, `cProfile`, `pyinstrument`, or framework-specific wrappers like `flask-pypprof` for Flask applications.
For Python < 3.4, refer to the `mprofile` documentation for manual installation and patching instructions. For newer Python versions, `mprofile` should be a more straightforward dependency.
Ensure your application runs on a `linux/amd64` environment if memory profiling is critical. Alternatively, disable memory profiling or explore other profiling tools that support your target architecture.