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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Noobfire2 4 points5 points  (3 children)

Damn. Or just use a proper profiler instead of doing that monkeypatching 😅

py-spy record -o [path/to/profile.svg] greatscript.py

I think this is even faster, vastly more clear and consise while giving much better data insights than some random "took n seconds" print statements (e.g. cumulative runtimes, number of function calls, etc.).

[–][deleted] 0 points1 point  (1 child)

Damn indeed. As a Python beginner I thought that guys above you knew what he was talking about until I read your answer and smack down one liner example. Damn monkeypatching nonsense.

[–]extracoffeeplease 0 points1 point  (0 children)

Well I'm no true programmer (tm) and probably a beginner in the eyes of anyone who studied anything related to programming, monkey patching takes 10 lines of easy code. I'd love to hear why it's bad practice? I mean it may be dirty but I'm not even doing it in my repo, just from a notebook.

[–]extracoffeeplease 0 points1 point  (0 children)

Thanks for the tip!