]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- pull out type() ahead of time to cut down on fn calls.
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 13 Jul 2010 15:55:08 +0000 (11:55 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 13 Jul 2010 15:55:08 +0000 (11:55 -0400)
Would replace this with set(dir(self)) but not sure if some
class schemes may have issues with dir() (also for low numbers
of args, not using the set() probably faster).

lib/sqlalchemy/ext/declarative.py

index ff0dc6bfc2202c0df2d41f412d03ca19404c88ef..909fb5cbaf9311f7fd95c80329b87381695be838 100755 (executable)
@@ -1162,11 +1162,12 @@ def _declarative_constructor(self, **kwargs):
     attributes of the instance's class are allowed. These could be,
     for example, any mapped columns or relationships.
     """
+    cls_ = type(self)
     for k in kwargs:
-        if not hasattr(type(self), k):
+        if not hasattr(cls_, k):
             raise TypeError(
                 "%r is an invalid keyword argument for %s" %
-                (k, type(self).__name__))
+                (k, cls_.__name__))
         setattr(self, k, kwargs[k])
 _declarative_constructor.__name__ = '__init__'