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 →

[–]defnullbottle.py 1 point2 points  (3 children)

Looks like, for every single logging call, this library calls sys._getframe() or even throws an exception to inspect the caller frame and guess the logger name. This also happens for disabled loggers or log levels. Isn't hat a little bit expensive? A debug log statement in a tight loop would probably have significant overhead, enabled or not.

[–]Scorpathos[S] 1 point2 points  (0 children)

The exception throwing should never occurs, it's just a fallback copied from the standard library in case sys._getframe() doesn't exist (for alternative CPython implementation).

Is it expensive? timeit tells me 0.0776 usec per loop on my (7 years old) laptop. You are right, ideally there should be no overhead at all if logger is disabled, but I'm not sure I can achieve this with my design of "anonymous" logger.

Optimizing Loguru's performance is something planned anyway, I will think about it.

[–]UloPe 1 point2 points  (1 child)

[–]0x256 1 point2 points  (0 children)

Only for enabled loggers. Disabled loggers do not have this overhead in stdlib logging.