[Python-ideas] Dynamic code NOPing

Chris Angelico rosuav at gmail.com
Wed Dec 26 06:48:50 CET 2012


On Wed, Dec 26, 2012 at 3:12 PM, Ned Batchelder <ned at nedbatchelder.com> wrote:
> Also, do you have an actual example of expensive logging?  I doubt your real
> code is logging the factorial of 2**15.   What is actually in your debug log
> that is expensive?  It will be much easier to discuss solutions if we are
> talking about actual problems.

Not specifically a Python logging issue, but what I periodically find
in my code is that there's an "internal representation" and an
"external representation" that have some sort of direct relationship.
I could easily log the internal form at many points, but that's not
particularly useful; logging the external involves either some hefty
calculations, or perhaps a linear search of some list of possibilities
(eg a reverse lookup of a constant - do you pay the cost of building
up a reverse dictionary, or just do the search?). Obviously that's
nothing like as expensive as 2**15!, but it makes more sense to be
logging "WM_MOUSEMOVE" than "Msg 512".

ChrisA



More information about the Python-ideas mailing list