[Python-ideas] Dynamic code NOPing
Haoyi Li
haoyi.sg at gmail.com
Wed Dec 26 03:50:21 CET 2012
More information about the Python-ideas mailing list
Wed Dec 26 03:50:21 CET 2012
- Previous message: [Python-ideas] Dynamic code NOPing
- Next message: [Python-ideas] Allow deleting slice in an OrderedDict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 at 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 at python.org > http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121226/35d6f1da/attachment.html>
- Previous message: [Python-ideas] Dynamic code NOPing
- Next message: [Python-ideas] Allow deleting slice in an OrderedDict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list