It takes a similar approach to profiling as rbspy, the profiler I worked on earlier this year – it can profile any running Python program, it uses process_vm_readv to read memory, and it by default displays profiling information in a really easy-to-use way.
Obviously, think this is SO COOL. Here’s what it looks like profiling a Python program: (gif taken from the github README)
It has this great top-like output by default. The default UI is somewhat similar to rbspy’s, but feels better executed to me :)
you can install it with pip!
Another thing he’s done that’s really nice is make it installable with
pip – you can run
py-spy and have it download a binary immediately! This is cool because, even though
py-spy is a
Rust program, obviously Python programmers are used to installing software with
pip and not
In the README he describes what he had to do to distribute a Rust executable with pip without requiring that users have a Rust compiler installed.
pyspy probably is more stable than rbspy!
Another nice thing
py-spy is that I believe it only uses Python’s public
Python.h). What I mean by “public bindings” is the header files you’d find in
rbspy by contrast uses a bunch of header files from inside the Ruby interpreter. This is because Python for whatever reason includes a lot more struct definitions in its header files.
- there are way fewer Python binding files (6 vs 42 for Ruby)
- each file is much smaller (~30kb vs 200kb for Ruby)
Basically what I think this means is that py-spy is likely to be easier to maintain longterm than rbspy – since rbspy depends on unstable internal Ruby interfaces, even though it works relatively well today, future versions of Ruby could break it at any time.
the start of an ecosystem of profilers in Rust?? :)
It turns out that phpspy is a sampling profiler for PHP, too!
I have this secret dream that we could eventually have a suite of open source profilers for lots of different programming languages that all have similar user interfaces. Today every single profiling tool is different and it’s a pain.
also rbspy has windows support now!
Ben also contributed Windows support to rbspy, which was amazing, and py-spy has Windows support from the start.
So if you want to profile Ruby or Python programs on Windows, you can!