summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-06-16 11:31:41 -0400
committerRob Crittenden <rcritten@redhat.com>2011-06-23 23:45:10 -0400
commitb02b77f8d777cf27a3f21155352e88c71db145c7 (patch)
tree872301c2d635aea12d225f0f0f10321b97d95a54 /ipalib/plugable.py
parent1717d638fc69d38ac5ed848847c7b01601c910dc (diff)
downloadfreeipa-b02b77f8d777cf27a3f21155352e88c71db145c7.tar.gz
freeipa-b02b77f8d777cf27a3f21155352e88c71db145c7.tar.xz
freeipa-b02b77f8d777cf27a3f21155352e88c71db145c7.zip
Slight performance improvement by not doing some checking in production mode
These changes save a few hundred ms but every little bit helps. ticket 1023
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 48ff91987..56546bba0 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -74,7 +74,8 @@ class SetProxy(ReadOnly):
if type(s) not in allowed:
raise TypeError('%r not in %r' % (type(s), allowed))
self.__s = s
- lock(self)
+ if not is_production_mode(self):
+ lock(self)
def __len__(self):
"""
@@ -293,9 +294,11 @@ class Registrar(DictProxy):
def __base_iter(self):
for (base, sub_d) in self.__allowed.iteritems():
- assert inspect.isclass(base)
+ if not is_production_mode(self):
+ assert inspect.isclass(base)
name = base.__name__
- assert not hasattr(self, name)
+ if not is_production_mode(self):
+ assert not hasattr(self, name)
setattr(self, name, MagicDict(sub_d))
yield (name, base)
@@ -308,7 +311,8 @@ class Registrar(DictProxy):
:param klass: The plugin class to find bases for.
"""
- assert inspect.isclass(klass)
+ if not is_production_mode(self):
+ assert inspect.isclass(klass)
found = False
for (base, sub_d) in self.__allowed.iteritems():
if issubclass(klass, base):
@@ -599,7 +603,8 @@ class API(DictProxy):
self.module = str(p.klass.__module__)
self.plugin = '%s.%s' % (self.module, self.name)
self.bases = tuple(b.__name__ for b in p.bases)
- lock(self)
+ if not is_production_mode(self):
+ lock(self)
plugins = {}
def plugin_iter(base, subclasses):
@@ -608,7 +613,8 @@ class API(DictProxy):
if klass not in plugins:
plugins[klass] = PluginInstance(klass)
p = plugins[klass]
- assert base not in p.bases
+ if not is_production_mode(self):
+ assert base not in p.bases
p.bases.append(base)
yield p.instance