summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2005-10-14 09:36:35 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2005-10-14 09:36:35 (GMT)
commit239322b97e40d55b7406b09b953ac4c1fe10dcc5 (patch)
treedc1ff375093591da095e7e1e6983e4f0934877b6 /Lib/logging
parent98fcaaf48e8ea2517dc505aba5bb8efe4182bc57 (diff)
downloadcpython-239322b97e40d55b7406b09b953ac4c1fe10dcc5.zip
cpython-239322b97e40d55b7406b09b953ac4c1fe10dcc5.tar.gz
cpython-239322b97e40d55b7406b09b953ac4c1fe10dcc5.tar.bz2
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).
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index db70293..24799fb 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