diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-09 14:36:23 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-09 14:36:23 -0400 |
| commit | 9afe585f4599d8114abe8d11f924c206a8962cda (patch) | |
| tree | dd734140049a3f0e744f43791bdf18971f33bbe6 /lib/sqlalchemy/util | |
| parent | fcfa62bd76ee0cdb125f0eb46ec4c1f625cbd6e7 (diff) | |
| download | sqlalchemy-9afe585f4599d8114abe8d11f924c206a8962cda.tar.gz | |
- pick around gaining modest dings in callcounts here and there
Diffstat (limited to 'lib/sqlalchemy/util')
| -rw-r--r-- | lib/sqlalchemy/util/_collections.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index a49848d08..84895182a 100644 --- a/lib/sqlalchemy/util/_collections.py +++ b/lib/sqlalchemy/util/_collections.py @@ -129,11 +129,13 @@ class _LW(AbstractKeyedTuple): def lightweight_named_tuple(name, fields): - tp_cls = type(name, (_LW,), {}) - for idx, field in enumerate(fields): - if field is None: - continue - setattr(tp_cls, field, property(operator.itemgetter(idx))) + tp_cls = type( + name, (_LW,), + dict([ + (field, _property_getters[idx]) + for idx, field in enumerate(fields) if field is not None + ]) + ) tp_cls._real_fields = fields tp_cls._fields = tuple([f for f in fields if f is not None]) @@ -747,6 +749,12 @@ ordered_column_set = OrderedSet populate_column_dict = PopulateDict +_getters = PopulateDict(operator.itemgetter) + +_property_getters = PopulateDict( + lambda idx: property(operator.itemgetter(idx))) + + def unique_list(seq, hashfunc=None): seen = {} if not hashfunc: |
