diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2015-05-30 04:21:39 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2015-05-30 04:21:39 (GMT) |
commit | 96c6af9b207c188c52ac53ce87bb7f2dea3f328b (patch) | |
tree | c556c00510282cac20410e324505ff5b257874c6 /Lib/collections | |
parent | 0a3297d7d4e042d8fbb884a029f0ef7ad8b00e46 (diff) | |
download | cpython-96c6af9b207c188c52ac53ce87bb7f2dea3f328b.zip cpython-96c6af9b207c188c52ac53ce87bb7f2dea3f328b.tar.gz cpython-96c6af9b207c188c52ac53ce87bb7f2dea3f328b.tar.bz2 |
Issue #16991: Add a C implementation of collections.OrderedDict.
Diffstat (limited to 'Lib/collections')
-rw-r--r-- | Lib/collections/__init__.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index fc60e13..6794de1 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -7,7 +7,6 @@ from _collections_abc import * import _collections_abc __all__ += _collections_abc.__all__ -from _collections import deque, defaultdict from operator import itemgetter as _itemgetter, eq as _eq from keyword import iskeyword as _iskeyword import sys as _sys @@ -16,7 +15,18 @@ from _weakref import proxy as _proxy from itertools import repeat as _repeat, chain as _chain, starmap as _starmap from reprlib import recursive_repr as _recursive_repr -MutableSequence.register(deque) +try: + from _collections import deque +except ImportError: + pass +else: + MutableSequence.register(deque) + +try: + from _collections import defaultdict +except ImportError: + pass + ################################################################################ ### OrderedDict @@ -264,6 +274,13 @@ class OrderedDict(dict): return dict.__eq__(self, other) +try: + from _collections import OrderedDict +except ImportError: + # Leave the pure Python version in place. + pass + + ################################################################################ ### namedtuple ################################################################################ |