File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717import subprocess
1818import logging
1919
20- from collections import OrderedDict
2120
2221# TODO: provide alternative when multiprocessing is not available
2322try :
@@ -1012,26 +1011,18 @@ def choose_backend(new_backend=None):
10121011 setup one of the allowable backends
10131012 """
10141013
1015- backends = OrderedDict ( [
1014+ backends = [
10161015 ('psutil' , has_psutil ),
10171016 ('posix' , os .name == 'posix' ),
10181017 ('tracemalloc' , has_tracemalloc ),
10191018 ('no_backend' , True )
1020- ])
1019+ ]
1020+ backends_indices = {b [0 ]: i for i , b in enumerate (backends )}
10211021
1022- def move_to_start (d , key ):
1023- """
1024- Emulation of OrderedDict.move_to_end(last=False) for old versions of Python
1025- """
1026- items = [(key , d [key ])]
1027- for _key , _value in d .items ():
1028- if _key != key :
1029- items .append ((_key , _value ))
1030- return OrderedDict (items )
10311022 if new_backend is not None :
1032- backends = move_to_start ( backends , new_backend )
1023+ backends . insert ( 0 , backends . pop ( backends_indices [ new_backend ]) )
10331024
1034- for n_backend , is_available in backends . items () :
1025+ for n_backend , is_available in backends :
10351026 if is_available :
10361027 global _backend
10371028 _backend = n_backend
You can’t perform that action at this time.
0 commit comments