Bitcoin Support Your contribution funds and supports Keyrox's website

New Py-Spy Python app profiler uses Rust for speed and safety

A new sampling profiler tool for Python developers, Py-Spy, gathers statistics about running Python programs without needing to instrument the code or even restart a running application.

Written by developer Ben Frederickson, Py-Spy can be installed via Python’s pip installer, and it runs on both Linux and Windows. This makes it uncomplicated to set up and useful in most any environment where Python is running.

Most profiling systems for Python, says Frederickson in his project’s notes, require changes to the source code to instrument the application. Aside from the possible hassles of modifying source, this also means the profiling code has to run in the same process as the app itself. “This means it’s not generally safe to use these profilers for debugging issues in production services since they will usually have a noticeable impact on performance,” he writes.


A live profile of a running Python script. Stats are sampled from the Python executable and can be sorted according to overall time or percentage of time used.

Py-Spy takes a different approach. It runs as a separate process, takes in the process ID of the Python app to analyze, and and uses the kernel-level APIs on the platform where it’s running to read the app’s memory. This way, claims Frederickson, Py-Spy is safe to use in production.

Read More…

Leave a Reply

1 + twelve =