This patch adds the production mode test to a few more places in the
code. The speed increase is slight, a few hundred ms in my tests, but
every little bit helps.
ticket 1023
rob
>From 3eae1ef4f31a4ec5d1f9e16b2c9bc06f8ea41cf8 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Thu, 16 Jun 2011 11:31:41 -0400
Subject: [PATCH] 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
---
ipalib/plugable.py | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 48ff919..56546bb 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
--
1.7.4
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel