r/learnpython • u/QuasiEvil • Oct 08 '26
logging and timing...then getting rid of it
I was just working on a project where I included a lot of logging and timing decorators/context managers (it involved event loops and async queues and such). Once I figured stuff out, I wanted to remove all this stuff. This isn't necessarily that hard, but it did make me wonder if there's a better way to do this in the first place. I suppose I'm imaging some way of marking these code pieces to be ignored by the interpreter or something?
(yeah yeah "ask AI to remove it")
1
Upvotes
View all comments
Show parent comment
4
u/Lumethys Oct 08 '26
python's slowness can add overhead too, why dont you rewrite your app in Rust? Or better yet, in Assembly.
When talking performance, talk about the concrete issue, how many seconds it has cost you per how many request? Exactly how much money does it cost?
People spend days to optimize something that would save 5 cents per million years, it's even had a name "Premature Optimization" - "the root of all evils". Your time is worth more than that.
Tell you what? There is a whole INDUSTRY about ADDING logging and timing (or, it's formal name "Metrics") infrastructure to project, it's called DevOps, and the work is Observability, or O11Y
Here a video on how bilibili migrate their metrics sink to handle 80 MILLIONS data points PER SECOND: https://www.youtube.com/watch?v=7uNXllJQlxE