diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-01-29 16:09:14 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-01-29 16:09:14 +0000 |
| commit | 10dbde43dbeeb713a9cc428b71c4fa59535f2e83 (patch) | |
| tree | f06c50844e01ef8466ff5916e400f0d4119b023c /lib/sqlalchemy | |
| parent | 966119f4d31ec511930024ad4b12d5e53cc8a6ec (diff) | |
| download | sqlalchemy-10dbde43dbeeb713a9cc428b71c4fa59535f2e83.tar.gz | |
- The per-dialect cache used by TypeEngine to cache
dialect-specific types is now a WeakKeyDictionary.
This to prevent dialect objects from
being referenced forever for an application that
creates an arbitrarily large number of engines
or dialects. There is a small performance penalty
which will be resolved in 0.6. [ticket:1299]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/types.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 9ffd4d183..8d47a2cf5 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -24,7 +24,7 @@ __all__ = [ 'TypeEngine', 'TypeDecorator', 'AbstractType', import inspect import datetime as dt from decimal import Decimal as _python_Decimal - +import weakref from sqlalchemy import exc from sqlalchemy.util import pickle import sqlalchemy.util as util @@ -125,14 +125,14 @@ class TypeEngine(AbstractType): try: return self._impl_dict[dialect] except AttributeError: - self._impl_dict = {} + self._impl_dict = weakref.WeakKeyDictionary() # will be optimized in 0.6 return self._impl_dict.setdefault(dialect, dialect.type_descriptor(self)) except KeyError: return self._impl_dict.setdefault(dialect, dialect.type_descriptor(self)) def __getstate__(self): d = self.__dict__.copy() - d['_impl_dict'] = {} + d['_impl_dict'] = weakref.WeakKeyDictionary() # will be optimized in 0.6 return d def get_col_spec(self): @@ -223,7 +223,7 @@ class TypeDecorator(AbstractType): try: return self._impl_dict[dialect] except AttributeError: - self._impl_dict = {} + self._impl_dict = weakref.WeakKeyDictionary() # will be optimized in 0.6 except KeyError: pass |
