Skip to content

Commit a54cadc

Browse files
authored
Merge pull request #13 from whtsky/feat/dict_python_3.7
feat: use built-in dict instead of OrderedDict on Python >= 3.7
2 parents ae66158 + fcd1ae6 commit a54cadc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bencoder.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
__version__ = '1.2.1'
1616

1717

18-
try:
19-
from collections import OrderedDict
20-
except ImportError:
21-
from ordereddict import OrderedDict
2218

23-
from cpython.version cimport PY_MAJOR_VERSION
19+
from cpython.version cimport PY_MAJOR_VERSION, PY_MINOR_VERSION
2420
IS_PY2 = PY_MAJOR_VERSION == 2
2521
if IS_PY2:
2622
END_CHAR = 'e'
@@ -29,6 +25,10 @@ else:
2925
END_CHAR = ord('e')
3026
ARRAY_TYPECODE = 'b'
3127

28+
if PY_MAJOR_VERSION >= 3 and PY_MINOR_VERSION >=7:
29+
OrderedDict = dict
30+
else:
31+
from collections import OrderedDict
3232

3333
class BTFailure(Exception):
3434
pass

0 commit comments

Comments
 (0)