forked from graphql-python/graphql-core-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If using Python >=3.7, use built-in dict as OrderedDict (graphql-pyth…
…on#248) If using Python >=3.7, use built-in dict as OrderedDict Since dictionaries are specified to preserve insertion order in Python 3.7 and up (see https://docs.python.org/3/whatsnew/3.7.html), it seems simplest and most performant to use the built-in type where possible.
- Loading branch information
Showing
3 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
try: | ||
# Try to load the Cython performant OrderedDict (C) | ||
# as is more performant than collections.OrderedDict (Python) | ||
from cyordereddict import OrderedDict # type: ignore | ||
except ImportError: | ||
from collections import OrderedDict | ||
import sys | ||
|
||
if sys.version_info >= (3, 7): | ||
# As of Python 3.7, dictionaries are specified to preserve insertion order | ||
OrderedDict = dict | ||
|
||
else: | ||
try: | ||
# Try to load the Cython performant OrderedDict (C) | ||
# as is more performant than collections.OrderedDict (Python) | ||
from cyordereddict import OrderedDict # type: ignore | ||
except ImportError: | ||
from collections import OrderedDict | ||
|
||
|
||
__all__ = ["OrderedDict"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters