diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-16 17:56:53 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-16 17:56:53 -0400 |
| commit | 747250587491ad76e30177b232daec5928f5b36d (patch) | |
| tree | 3b27160c4ff9d67c2230146a360bbe07c8b555c5 /lib | |
| parent | 8f04c5319120773906161548b82a8d83e387843e (diff) | |
| download | sqlalchemy-747250587491ad76e30177b232daec5928f5b36d.tar.gz | |
- justify NamedTuple, now called KeyedTuple
- fix this test
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/loading.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/__init__.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/_collections.py | 13 |
3 files changed, 13 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index 41b82d8d1..789e7dda3 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -70,7 +70,7 @@ def instances(query, cursor, context): elif single_entity: rows = [process[0](row, None) for row in fetch] else: - rows = [util.NamedTuple([proc(row, None) for proc in process], + rows = [util.KeyedTuple([proc(row, None) for proc in process], labels) for row in fetch] if filtered: diff --git a/lib/sqlalchemy/util/__init__.py b/lib/sqlalchemy/util/__init__.py index 313c6b02c..65a06c28d 100644 --- a/lib/sqlalchemy/util/__init__.py +++ b/lib/sqlalchemy/util/__init__.py @@ -9,7 +9,7 @@ from compat import callable, cmp, reduce, defaultdict, py25_dict, \ update_wrapper, partial, md5_hex, decode_slice, dottedgetter,\ parse_qsl, any, contextmanager, namedtuple, next, WeakSet -from _collections import NamedTuple, ImmutableContainer, immutabledict, \ +from _collections import KeyedTuple, ImmutableContainer, immutabledict, \ Properties, OrderedProperties, ImmutableProperties, OrderedDict, \ OrderedSet, IdentitySet, OrderedIdentitySet, column_set, \ column_dict, ordered_column_set, populate_column_dict, unique_list, \ diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index 801a79e9a..af3be8ec3 100644 --- a/lib/sqlalchemy/util/_collections.py +++ b/lib/sqlalchemy/util/_collections.py @@ -16,10 +16,19 @@ from compat import time_func, threading EMPTY_SET = frozenset() -class NamedTuple(tuple): +class KeyedTuple(tuple): """tuple() subclass that adds labeled names. - Is also pickleable. + Unlike collections.namedtuple, this is + an ad-hoc data structure, not a factory + for new types. + + It's pickleable in-place without the need for stack + frame manipulation, new KeyedTuple types can be created + very quickly and simply (look at the source + to collections.namedtuple for contrast). + + Is used by :class:`.Query` to return result rows. """ |
