]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- strategies + declarative
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 4 Jan 2015 23:30:25 +0000 (18:30 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 4 Jan 2015 23:30:25 +0000 (18:30 -0500)
lib/sqlalchemy/ext/declarative/clsregistry.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/sql/visitors.py

index 3ef63a5aeb7f8fd4370bbb3fc9455650ee405162..d2a09d823ef7fbab57284e5e1103eff2a047c0a1 100644 (file)
@@ -71,6 +71,8 @@ class _MultipleClassMarker(object):
 
     """
 
+    __slots__ = 'on_remove', 'contents', '__weakref__'
+
     def __init__(self, classes, on_remove=None):
         self.on_remove = on_remove
         self.contents = set([
@@ -127,6 +129,8 @@ class _ModuleMarker(object):
 
     """
 
+    __slots__ = 'parent', 'name', 'contents', 'mod_ns', 'path', '__weakref__'
+
     def __init__(self, name, parent):
         self.parent = parent
         self.name = name
@@ -172,6 +176,8 @@ class _ModuleMarker(object):
 
 
 class _ModNS(object):
+    __slots__ = '__parent',
+
     def __init__(self, parent):
         self.__parent = parent
 
@@ -193,6 +199,8 @@ class _ModNS(object):
 
 
 class _GetColumns(object):
+    __slots__ = 'cls',
+
     def __init__(self, cls):
         self.cls = cls
 
@@ -221,6 +229,8 @@ inspection._inspects(_GetColumns)(
 
 
 class _GetTable(object):
+    __slots__ = 'key', 'metadata'
+
     def __init__(self, key, metadata):
         self.key = key
         self.metadata = metadata
index bff73258c63ae31019f63fce66216c01051e4cae..68b86268cad9f7b70e680ebdae7fcdf4054c52bf 100644 (file)
@@ -560,6 +560,8 @@ class LoaderStrategy(object):
 
     """
 
+    __slots__ = 'parent_property', 'is_class_level', 'parent', 'key'
+
     def __init__(self, parent):
         self.parent_property = parent
         self.is_class_level = False
index d95f17f648e3df9ceb744911a314e59f89fc12e7..4e47a8f249a5d9e3494f19e78fc3c223edc83b60 100644 (file)
@@ -105,6 +105,8 @@ class UninstrumentedColumnLoader(LoaderStrategy):
     if the argument is against the with_polymorphic selectable.
 
     """
+    __slots__ = 'columns',
+
     def __init__(self, parent):
         super(UninstrumentedColumnLoader, self).__init__(parent)
         self.columns = self.parent_property.columns
@@ -128,6 +130,8 @@ class UninstrumentedColumnLoader(LoaderStrategy):
 class ColumnLoader(LoaderStrategy):
     """Provide loading behavior for a :class:`.ColumnProperty`."""
 
+    __slots__ = 'columns', 'is_composite'
+
     def __init__(self, parent):
         super(ColumnLoader, self).__init__(parent)
         self.columns = self.parent_property.columns
@@ -176,6 +180,8 @@ class ColumnLoader(LoaderStrategy):
 class DeferredColumnLoader(LoaderStrategy):
     """Provide loading behavior for a deferred :class:`.ColumnProperty`."""
 
+    __slots__ = 'columns', 'group'
+
     def __init__(self, parent):
         super(DeferredColumnLoader, self).__init__(parent)
         if hasattr(self.parent_property, 'composite_class'):
@@ -300,6 +306,8 @@ class LoadDeferredColumns(object):
 class AbstractRelationshipLoader(LoaderStrategy):
     """LoaderStratgies which deal with related objects."""
 
+    __slots__ = 'mapper', 'target', 'uselist'
+
     def __init__(self, parent):
         super(AbstractRelationshipLoader, self).__init__(parent)
         self.mapper = self.parent_property.mapper
@@ -316,6 +324,8 @@ class NoLoader(AbstractRelationshipLoader):
 
     """
 
+    __slots__ = ()
+
     def init_class_attribute(self, mapper):
         self.is_class_level = True
 
@@ -343,6 +353,10 @@ class LazyLoader(AbstractRelationshipLoader):
 
     """
 
+    __slots__ = (
+        '_lazywhere', '_rev_lazywhere', 'use_get', '_bind_to_col',
+        '_equated_columns', '_rev_bind_to_col', '_rev_equated_columns')
+
     def __init__(self, parent):
         super(LazyLoader, self).__init__(parent)
         join_condition = self.parent_property._join_condition
@@ -647,6 +661,8 @@ class LazyLoader(AbstractRelationshipLoader):
 class LoadLazyAttribute(object):
     """serializable loader object used by LazyLoader"""
 
+    __slots__ = 'key',
+
     def __init__(self, key):
         self.key = key
 
@@ -661,6 +677,8 @@ class LoadLazyAttribute(object):
 
 @properties.RelationshipProperty.strategy_for(lazy="immediate")
 class ImmediateLoader(AbstractRelationshipLoader):
+    __slots__ = ()
+
     def init_class_attribute(self, mapper):
         self.parent_property.\
             _get_strategy_by_cls(LazyLoader).\
@@ -684,6 +702,8 @@ class ImmediateLoader(AbstractRelationshipLoader):
 @log.class_logger
 @properties.RelationshipProperty.strategy_for(lazy="subquery")
 class SubqueryLoader(AbstractRelationshipLoader):
+    __slots__ = 'join_depth',
+
     def __init__(self, parent):
         super(SubqueryLoader, self).__init__(parent)
         self.join_depth = self.parent_property.join_depth
@@ -1069,6 +1089,9 @@ class JoinedLoader(AbstractRelationshipLoader):
     using joined eager loading.
 
     """
+
+    __slots__ = 'join_depth',
+
     def __init__(self, parent):
         super(JoinedLoader, self).__init__(parent)
         self.join_depth = self.parent_property.join_depth
index bb525744a4198874ea084927191db6318ac1c321..d09b82148e9c35855f4860e5dd874fce44e8442d 100644 (file)
@@ -51,6 +51,7 @@ class VisitableType(type):
 
     Classes having no __visit_name__ attribute will remain unaffected.
     """
+
     def __init__(cls, clsname, bases, clsdict):
         if clsname != 'Visitable' and \
                 hasattr(cls, '__visit_name__'):