2 ms·
It's not always a nanosecond, some string representations can take a while to create. In poorly coded Django models they could involve a trip to the database.
by orf 7y ago
It's not always a nanosecond, some string representations can take a while to create. In poorly coded Django models they could involve a trip to the database.
- mixmastamyk 7y agoif logger.isEnabledFor(logging.DEBUG): logger.debug(f'{expensive_func()}')
- orf 7y agoI hope that’s a joke, because that is a verbose and ridiculous way of duplicating the work that the logging module does, while also making the code less readable and maintainable!
- mixmastamyk 7y agoThat’s how you defer an expensive function. The fstring part is the joke.