bpo-34838: Perform a more easily branch-predictable type check by ammaraskar · Pull Request #9659 · python/cpython (original) (raw)

Why only tuple and dict? Same fast path would apply to all types with fast subclass flags from object.h (

cpython/Include/object.h

Line 660 ine42b705

/* These flags are used to determine if a type is a subclass. */

), including int, list, bytes, str, BaseException and type.