Guido van Rossum added the comment:

I agree with Raymond -- this is a common pattern but there are many variations 
that are hard to catch in a single implementation. E.g. at Dropbox we have a 
decorator like this that lets you specify an identifier for the block you name, 
and which logs the measured times to a special log file. Then there is separate 
analysis software that shows the plots the average time for each named block 
over time. Incredibly useful, but hard to share the code.

I think that Jeff Preshing's blog post giving the basic idea (to which Steven's 
recipe links) is more useful than a implementation in the stdlib could ever be. 
Steven's class already has three keyword arguments, and that feels like either 
not enough or already too many, depending on your needs. It's too easy to 
bikeshed it to death. (E.g. the "disable+restore gc" feature could easily be 
moved into a separate decorator; and why not make the verbose printing a little 
more flexible by adding another parameter to either specify the file to print 
to or the function to be used to print. Oh, and the message could be 
customizable. Then again, you might want to subclass this in order to do all 
those customizations, eventually allowing this to be used as the basis for e.g. 
the Dropbox version. Etc. Not that I propose to go that way -- I'm just 
bringing this up to indicate how hopeless it would be to try and put some 
version in the stdlib.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19495>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to