diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-03-09 17:26:16 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-03-09 17:26:16 -0500 |
| commit | c8a80e21301791fd4e1caf29ed8cadd40f617765 (patch) | |
| tree | bcd5a91a5b841501a1d237e95595f2177cf5c2b8 /lib/sqlalchemy/util/_collections.py | |
| parent | 8ef3ed1032e0354cffa786f25bac2c54a3bcd54d (diff) | |
| download | sqlalchemy-c8a80e21301791fd4e1caf29ed8cadd40f617765.tar.gz | |
- remove all compat items that are pre-2.5 (hooray)
- other cleanup
- don't need compat.decimal, that approach never panned out. hopefully
outside libs aren't pulling it in, they shouldn't be
Diffstat (limited to 'lib/sqlalchemy/util/_collections.py')
| -rw-r--r-- | lib/sqlalchemy/util/_collections.py | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index ca77103b2..2c9c982fb 100644 --- a/lib/sqlalchemy/util/_collections.py +++ b/lib/sqlalchemy/util/_collections.py @@ -6,7 +6,6 @@ """Collection classes and helpers.""" -import sys import itertools import weakref import operator @@ -649,37 +648,25 @@ class OrderedIdentitySet(IdentitySet): self.add(o) -if sys.version_info >= (2, 5): - class PopulateDict(dict): - """A dict which populates missing values via a creation function. +class PopulateDict(dict): + """A dict which populates missing values via a creation function. - Note the creation function takes a key, unlike - collections.defaultdict. + Note the creation function takes a key, unlike + collections.defaultdict. - """ - - def __init__(self, creator): - self.creator = creator - - def __missing__(self, key): - self[key] = val = self.creator(key) - return val -else: - class PopulateDict(dict): - """A dict which populates missing values via a creation function.""" + """ - def __init__(self, creator): - self.creator = creator + def __init__(self, creator): + self.creator = creator - def __getitem__(self, key): - try: - return dict.__getitem__(self, key) - except KeyError: - self[key] = value = self.creator(key) - return value + def __missing__(self, key): + self[key] = val = self.creator(key) + return val -# define collections that are capable of storing +# Define collections that are capable of storing # ColumnElement objects as hashable keys/elements. +# At this point, these are mostly historical, things +# used to be more complicated. column_set = set column_dict = dict ordered_column_set = OrderedSet |
