
I think the lambda: solution really is the best solution. The additional cost is the construction of one function object and one invocation per logging call, which i suspect is about the lower limit. It's also the most generally applicable: it has nothing specific to logging in it at all! So it seems to me that if we were to change anything, improving the lambdas (shorter syntax and/or optimizing away the overhead) would be the way to go over some string-interpolation-logging-specific special case in the interpreter. On Wed, Dec 26, 2012 at 5:49 AM, Greg Ewing <greg.ewing@canterbury.ac.nz>wrote:
Rene Nejsum wrote:
Interessting alternatives, but they do not quite come on as flexible/usefull enough…
Often debug statements have a lot of text and variables, like:
log.debug( "The value of X, Y, Z is now: %d %s %d" % ( x, lookup(y), factorial(2**15))
That needn't be a problem:
log.lazydebug(lambda: "The value of X, Y, Z is now: %d %s %d" % (x, lookup(y), factorial(2**15)))
-- Greg
______________________________**_________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>