From: Vinay Sajip Date: Fri, 14 Oct 2005 09:37:54 +0000 (+0000) Subject: Optimised Placeholders handling of child loggers by using a dict rather than a list... X-Git-Tag: v2.4.3c1~240 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a479c2e8cf01d831a8244ffab41de55ea2cea1b3;p=thirdparty%2FPython%2Fcpython.git Optimised Placeholders handling of child loggers by using a dict rather than a list (much slower in the pathological case of hundreds of child Loggers to a Placeholder - problem reported by Ryan Blazecka). --- diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index db7029321d30..24799fb1bbbb 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -783,14 +783,17 @@ class PlaceHolder: """ Initialize with the specified logger being a child of this placeholder. """ - self.loggers = [alogger] + #self.loggers = [alogger] + self.loggerMap = { alogger : None } def append(self, alogger): """ Add the specified logger as a child of this placeholder. """ - if alogger not in self.loggers: - self.loggers.append(alogger) + #if alogger not in self.loggers: + if not self.loggerMap.has_key(alogger): + #self.loggers.append(alogger) + self.loggerMap[alogger] = None # # Determine which class to use when instantiating loggers. @@ -892,7 +895,8 @@ class Manager: Ensure that children of the placeholder ph are connected to the specified logger. """ - for c in ph.loggers: + #for c in ph.loggers: + for c in ph.loggerMap.keys(): if string.find(c.parent.name, alogger.name) <> 0: alogger.parent = c.parent c.parent = alogger