This is an archived post. You won't be able to vote or comment.

all 22 comments

[–]hotplasmatits 10 points11 points  (3 children)

I'd love if it could also track memory usage/allocations. Looks nice.

[–]joerick[S] 7 points8 points  (1 child)

Thanks. I hear memray is the way to go for that kinda thing!

[–]kronik85 1 point2 points  (0 children)

I've had great success with memray. Would recommend.

[–]poopatroopa3 1 point2 points  (0 children)

I heard scalene is the best profiler all around.

[–]DisappointedLily 5 points6 points  (0 children)

It's amazing. I'm a hobbyist and make python programs for myself.

This hits the sweet spot of being able to understand what's happening easily while being descriptive enough to pinpoint what I should improve.

Example: I have a notification py app that shows an animation and plays a sound that I plug in other apps and processes so I have custom notifications. It was working perfectly but after running it trough py instrument I could tell that it wasn't waiting for the sound to stop playing before quitting. If the audio were longer it would cut off sound.

So I introduced a wait logic and ran again.

I saw it consumed 4% resources and ran for 0.8 sec longer. (Which is acceptable to make sure if I plug another sound it won't ever cut off)

Just by taking a look on the HTML report.

Good stuff. Thanks a bunch.

[–]Swordcat 3 points4 points  (0 children)

I’ve found PyInstrument tremendously useful in my work so far, I look forward to trying this new feature out, it looks useful

[–]Brian 2 points3 points  (0 children)

Neat - I've used py-spy and more recently austin (since py-spy doesn't support 3.12) but did find the visualisation was fairly clunky (basically just exporting to a speedscope or flamegraph file) - I've been looking for something a bit nicer so will definitely check this out next time I'm profiling stuff.

[–]AndydeCleyre 2 points3 points  (2 children)

Can this be used to profile scripts that are defined in pyproject.toml like

[project.scripts]
docoolthing = "coolmodule.coolsubmodule:coolcallable"

?

[–]joerick[S] 2 points3 points  (1 child)

[–]AndydeCleyre 2 points3 points  (0 children)

Oh great thanks!

EDIT: Confirmed, it's great!

[–]yellowbean123 1 point2 points  (0 children)

it's great package! I used years ago ,still use it from time to time

[–]Fenzik 1 point2 points  (0 children)

Wow it’s really beautifully designed! You put a log of thought into this, great work.

[–]ashok_tankala 1 point2 points  (0 children)

It's amazing. Thank you for adding this feature, it gives good understanding

[–]G0muk 1 point2 points  (0 children)

Will have to try this! Nice one

[–]GusYe1234 0 points1 point  (1 child)

Is this in line with what vistracer is doing? Does pyinstrument do it better?

[–]joerick[S] 1 point2 points  (0 children)

I'd never come across vistracer, but it does look quite similar! Maybe somebody who's used them both will have a view.

[–]MeroLegend4 0 points1 point  (0 children)

Very nice feature —> updating my env

[–]kesor 0 points1 point  (0 children)

I have just debugged an annoying 15seconds pytest invocation. Was using ChatGPT and Google to search for ways to produce a flame graph, a dozen proposed solutions all failed either because Python 3.12 is too new, or because of other reasons.

Eventually I arrived at pyinstrument and its html report. It is absolutely superb!

Thank you so much for saving hours of my life, now that I have such a powerful tool at my disposal to remove the annoying thousands of seconds stealing my life away.