# \[Pitch #2\] Add \`isKnownIdentical\` Method for Quick Comparisons to \`Equatable\`

**URL:** <https://forums.swift.org/t/pitch-2-add-isknownidentical-method-for-quick-comparisons-to-equatable/80497>\
**Category:** Pitches\
**Created:** [June 16, 2025, 6:00pm UTC](https://forums.swift.org/t/pitch-2-add-isknownidentical-method-for-quick-comparisons-to-equatable/80497 "2025-06-16T18:00:31Z")\
**Posts on this page:** 1\
**Showing post:** 45

<div class="post-metadata">

**Author:** ![vanvoorden](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/vanvoorden/32/33619_2.png) [@vanvoorden](https://forums.swift.org/u/vanvoorden)\
**Post date:** [June 20, 2025, 7:23am UTC](https://forums.swift.org/t/pitch-2-add-isknownidentical-method-for-quick-comparisons-to-equatable/80497/45 "2025-06-20T07:23:36Z")

</div>

> [@ktoso](#):
>
> I wanted to add some prior art here; recently as we were adding `isIsolatingCurrentContext` to `Executor` which serves a similar purpose, we also opted to go with `Bool?` in order to be able to determine the "we don't know" vs "definitely no". It is an useful piece of information to have and I do think it fits this API design proposed here as well.

There's also this public-but-underscored example on `Sequence`:

> [@\[Pitch\] \`Distinguishable\` protocol for Quick Comparisons](https://forums.swift.org/t/pitch-distinguishable-protocol-for-quick-comparisons/79145/16):
>
> One data point is that `Sequence` actually has a semi-hidden customization point that uses the `Bool?` tripartite result for containment checks: `_customContainsEquatableElement`:
> 
> [swift/stdlib/public/core/Sequence.swift at main · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/blob/main/stdlib/public/core/Sequence.swift#L358-L387)
> 
> This method uses an optional result because not every collection can provide a speed increase over a linear search, like `Array`. For collections that can, like `Set` or `Range`, the implementation of this method lets them provide fast containment checks even in generic contexts.

Here is the default implementation that returns `nil`:

> <https://github.com/swiftlang/swift/blob/swift-6.1.2-RELEASE/stdlib/public/core/Sequence.swift#L775-L779>

And here's where we use that `nil` to perform some conditional logic:

> <https://github.com/swiftlang/swift/blob/swift-6.1.2-RELEASE/stdlib/public/core/SequenceAlgorithms.swift#L566-L573>

---

_[View the full topic](https://forums.swift.org/t/pitch-2-add-isknownidentical-method-for-quick-comparisons-to-equatable/80497)._
