Closed
Description
There are two ways we can compare types for being the same:
- Semantic identity, this is what is done by
is_equivalent()
that just checksA <: B and B <: A
. This affects semantics of types in the user code being checked. - Representation identity, this is what is currently done by
Type.__eq__()
andType.__hash__()
. This affects internal bookkeeping, caching, etc.
Currently, is_same_types()
stays somewhere in the middle, it doesn't take into account some subtype relationships (including protocols and recursive type aliases), but it also "takes into account" make_simplified_union()
.
I could see how this can be a minor performance optimization for equivalence with respect to proper subtyping, but IMO this kind of middle ground position increases chance for confusion and bugs. I would propose to remove it and instead use ==
and is_equivalent()
.