[Python-Dev] Proposed additional keyword argument in logging calls

Vinay Sajip vinay_sajip at yahoo.co.uk
Fri Dec 2 20:54:41 CET 2005


> If the user doesn't need those values and can provide cheap substitutes,
> perhaps their computation can be avoided.  I did that recently by inlining
> only the parts of logging.LogRecord.__init__ in a subclass and avoided
> calling logging.LogRecord.__init__ altogether.  It generated lots of
> instance variables we never use and just slowed things down.

Well, that approach is fine if you need maximal performance. If those values 
set in LogRecord.__init__ can be computed more cheaply than they are at 
present, please give an idea as to where speedups can be applied, or even 
supply a patch ;-) If you don't need many of the values set by 
LogRecord.__init__, then your approach is fine (until someone decides they want 
something which is documented and tries to access it via a specific format 
string - which could be done, in the general case, via configuration changes).

The use case I'm supporting with this is one where some/most/all of the default 
attributes are wanted, and also additional user-defined ones in some special 
cases. With the proposed scheme the extra value is passed to LogRecord 
constuction code so it could be used by your custom LogRecord initialiser with 
the same benefit as in the general case (I think).

Regards,

Vinay Sajip



More information about the Python-Dev mailing list