▲ | leobuskin 8 days ago | ||||||||||||||||
As I understand, it may help a bit with logging performance, not sure, still trying to understand the template abilities. So, right now, you have two options to log: 1. `logger.debug(f'Processing {x}')` - looks great, but evaluates anyway, even if logging level > `logging.DEBUG`; 2. `logger.debug('Processing %s', x)` - won't evaluate till necessary. What would be the approach with t-strings in this case? Would we get any benefits? | |||||||||||||||||
▲ | bcoates 8 days ago | parent | next [-] | ||||||||||||||||
The expression (x) is eagerly evaluated in both cases, cuz that's how Python works. You can defer the format call but Python fundamentally doesn't have an equivalent of lazy/compile time flag argument evaluation and this doesn't change that. For a logger t-strings are mostly just a more pleasant and less bug-prone syntax for #2 | |||||||||||||||||
▲ | davepeck 8 days ago | parent | prev [-] | ||||||||||||||||
T-strings, like f-strings, are eagerly evaluated -- so in this sense, no, there's no benefit. | |||||||||||||||||
|