summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/properties.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/orm/properties.py')
-rw-r--r--lib/sqlalchemy/orm/properties.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 62ea93fb3..d51b6920d 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -34,6 +34,13 @@ class ColumnProperty(StrategizedProperty):
strategy_wildcard_key = 'column'
+ __slots__ = (
+ '_orig_columns', 'columns', 'group', 'deferred',
+ 'instrument', 'comparator_factory', 'descriptor', 'extension',
+ 'active_history', 'expire_on_flush', 'info', 'doc',
+ 'strategy_class', '_creation_order', '_is_polymorphic_discriminator',
+ '_mapped_by_synonym')
+
def __init__(self, *columns, **kwargs):
"""Provide a column-level property for use with a Mapper.
@@ -109,6 +116,7 @@ class ColumnProperty(StrategizedProperty):
**Deprecated.** Please see :class:`.AttributeEvents`.
"""
+ super(ColumnProperty, self).__init__()
self._orig_columns = [expression._labeled(c) for c in columns]
self.columns = [expression._labeled(_orm_full_deannotate(c))
for c in columns]
@@ -206,7 +214,7 @@ class ColumnProperty(StrategizedProperty):
elif dest_state.has_identity and self.key not in dest_dict:
dest_state._expire_attributes(dest_dict, [self.key])
- class Comparator(PropComparator):
+ class Comparator(util.MemoizedSlots, PropComparator):
"""Produce boolean, comparison, and other operators for
:class:`.ColumnProperty` attributes.
@@ -224,8 +232,10 @@ class ColumnProperty(StrategizedProperty):
:attr:`.TypeEngine.comparator_factory`
"""
- @util.memoized_instancemethod
- def __clause_element__(self):
+
+ __slots__ = '__clause_element__', 'info'
+
+ def _memoized_method___clause_element__(self):
if self.adapter:
return self.adapter(self.prop.columns[0])
else:
@@ -233,15 +243,14 @@ class ColumnProperty(StrategizedProperty):
"parententity": self._parentmapper,
"parentmapper": self._parentmapper})
- @util.memoized_property
- def info(self):
+ def _memoized_attr_info(self):
ce = self.__clause_element__()
try:
return ce.info
except AttributeError:
return self.prop.info
- def __getattr__(self, key):
+ def _fallback_getattr(self, key):
"""proxy attribute access down to the mapped column.
this allows user-defined comparison methods to be accessed.