summaryrefslogtreecommitdiff
path: root/SCons/Util/types.py
diff options
context:
space:
mode:
Diffstat (limited to 'SCons/Util/types.py')
-rw-r--r--SCons/Util/types.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/SCons/Util/types.py b/SCons/Util/types.py
index 9aef13ef9..1602055d6 100644
--- a/SCons/Util/types.py
+++ b/SCons/Util/types.py
@@ -12,7 +12,7 @@ import pprint
import re
from typing import Optional
-from collections import UserDict, UserList, UserString
+from collections import UserDict, UserList, UserString, deque
from collections.abc import MappingView
# Functions for deciding if things are like various types, mainly to
@@ -23,20 +23,22 @@ from collections.abc import MappingView
# exception, but handling the exception when it's not the right type is
# often too slow.
-# We are using the following trick to speed up these
-# functions. Default arguments are used to take a snapshot of
-# the global functions and constants used by these functions. This
-# transforms accesses to global variable into local variables
-# accesses (i.e. LOAD_FAST instead of LOAD_GLOBAL).
-# Since checkers dislike this, it's now annotated for pylint to flag
+# A trick is used to speed up these functions. Default arguments are
+# used to take a snapshot of the global functions and constants used
+# by these functions. This transforms accesses to global variables into
+# local variable accesses (i.e. LOAD_FAST instead of LOAD_GLOBAL).
+# Since checkers dislike this, it's now annotated for pylint, to flag
# (mostly for other readers of this code) we're doing this intentionally.
-# TODO: PY3 check these are still valid choices for all of these funcs.
+# TODO: experts affirm this is still faster, but maybe check if worth it?
DictTypes = (dict, UserDict)
-ListTypes = (list, UserList)
+ListTypes = (list, UserList, deque)
-# Handle getting dictionary views.
-SequenceTypes = (list, tuple, UserList, MappingView)
+# With Python 3, there are view types that are sequences. Other interesting
+# sequences are range and bytearray. What we don't want is strings: while
+# they are iterable sequences, in SCons usage iterating over a string is
+# almost never what we want. So basically iterable-but-not-string:
+SequenceTypes = (list, tuple, deque, UserList, MappingView)
# Note that profiling data shows a speed-up when comparing
# explicitly with str instead of simply comparing