4 ms·
f""-strings for logging is an example of "practicality beats purity" Yes, f""-strings may be evaluated unnecessarily (perhaps, t-strings could solve it). But i
by d0mine 1y ago
f""-strings for logging is an example of "practicality beats purity"
Yes, f""-strings may be evaluated unnecessarily (perhaps, t-strings could solve it). But in practice they are too convenient. Unless profiler says otherwise, it may be ok to use them in many circumstances.
- jackblemming 1y agoHeh, I get to totally dunk on this guy by calling him a vibe coder for not using lazy evaled string interpolation. Wait a second.. If I do ANY ACTUAL engineering and log out the time savings, it's completely negligible and just makes the code harder to read? It is complete insanity to me that literally every piece of programming literature over the past sixty years has been drilling the concept about code readability over unncessary optimizations and yet still I constantly read completely backwards takes like this.
- hiAndrewQuinn 1y agoHaving strong opinions on technical errata makes you sound smart and like you know what you're doing to the people who might want to hire you. Saying "I didn't bother to optimize this because it doesn't affect our bottom line" can be so easily reinterpreted as "I'm incompetent and never even thought about this angle in the first place". The OP has chosen an effective middle ground to communicate that they're serious about their work.
- _alternator_ 1y agoYeah, so like I said, it’s not a problem, until it is. The gist of the article is that “LLMs let me add a lot of useful debugging messages to my logs”, that’s great, I use them for log messages too, but not with f-strings. The footgun is there. Hot-loop debug logging can cost a ton with f-strings, and an LLM can just as easily use the standard log formatting without this problem. Few people use a profiler prior to a production bug (or just end up with eye popping autoscaling bills). Shrug. I guess everyone can learn for themselves if it’s a problem for them. But I’ve been there; it would be nice if the tools did better with best practices.