diff --git a/Doc/library/secrets.rst b/Doc/library/secrets.rst index 3b5b57fb1c21702..842e8c512def139 100644 --- a/Doc/library/secrets.rst +++ b/Doc/library/secrets.rst @@ -137,7 +137,7 @@ Other functions :term:`bytes-like objects ` *a* and *b* are equal, otherwise ``False``, using a "constant-time compare" to reduce the risk of - `timing attacks `_. + `timing attacks `__. See :func:`hmac.compare_digest` for additional details. diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 20f1e728733fec6..3a9e52fbea41ad2 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -1286,7 +1286,7 @@ def __init__(self, initlist=None): self.data = [] if initlist is not None: # XXX should this accept an arbitrary sequence? - if type(initlist) == type(self.data): + if type(initlist) is list: self.data[:] = initlist elif isinstance(initlist, UserList): self.data[:] = initlist.data[:] @@ -1335,21 +1335,21 @@ def __delitem__(self, i): def __add__(self, other): if isinstance(other, UserList): return self.__class__(self.data + other.data) - elif isinstance(other, type(self.data)): + elif isinstance(other, list): return self.__class__(self.data + other) return self.__class__(self.data + list(other)) def __radd__(self, other): if isinstance(other, UserList): return self.__class__(other.data + self.data) - elif isinstance(other, type(self.data)): + elif isinstance(other, list): return self.__class__(other + self.data) return self.__class__(list(other) + self.data) def __iadd__(self, other): if isinstance(other, UserList): self.data += other.data - elif isinstance(other, type(self.data)): + elif isinstance(other, list): self.data += other else: self.data += list(other) diff --git a/Misc/NEWS.d/next/Library/2026-07-21-13-33-00.gh-issue-154359.rst b/Misc/NEWS.d/next/Library/2026-07-21-13-33-00.gh-issue-154359.rst new file mode 100644 index 000000000000000..7ef4b781253e0da --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-21-13-33-00.gh-issue-154359.rst @@ -0,0 +1 @@ +Optimize the type checks in :class:`collections.UserList` to use the :class:`list` type directly instead of ``type(self.data)``.