# The Perfect Follow-Up to Dictionary Performance - mapKeyedValues (SE-0510)

**URL:** <https://forums.swift.org/t/the-perfect-follow-up-to-dictionary-performance-mapkeyedvalues-se-0510/87602>\
**Category:** Using Swift\
**Tags:** swift, wwdc\
**Created:** [June 22, 2026, 6:23pm UTC](https://forums.swift.org/t/the-perfect-follow-up-to-dictionary-performance-mapkeyedvalues-se-0510/87602 "2026-06-22T18:23:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Okariuss](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/okariuss/32/45430_2.png) [@Okariuss](https://forums.swift.org/u/Okariuss)\
**Post date:** [June 22, 2026, 6:23pm UTC](https://forums.swift.org/t/the-perfect-follow-up-to-dictionary-performance-mapkeyedvalues-se-0510/87602/1 "2026-06-22T18:23:22Z")

</div>

Before WWDC26, I published an article called “[Advanced Dictionaries: Performance and Hidden Traps.](https://medium.com/icommunity/advanced-dictionaries-performance-and-hidden-traps-01921daaa164)” In that article, I explained why mapValues(\_:) is very fast because it reuses the same hash structure and memory slots. However, we had a big problem: mapValues does not give us the keys inside the closure. To use keys, we had to choose slow methods like reduce(into:) which cause a lot of rehashing.

At WWDC26, Apple solved this problem with Dictionary.mapKeyedValues [(SE-0510)](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0510-dictionary-mapvalues-with-keys.md).

I wrote a new follow-up article that connects my previous dictionary performance notes with this new API. In this short post, I talk about:

- A quick recap of older performance traps like uniqueKeysWithValues.
- How mapKeyedValues lets us use keys as context with less performance tax.

You can read the article [here](https://medium.com/icommunity/wwdc26-powerful-new-addition-to-swift-dictionaries-mapkeyedvalues-2180fcebc26e)

I would love to hear your thoughts on this new API and my article

---

<div class="post-metadata">

**Author:** ![ibex](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ibex/32/30439_2.png) [@ibex](https://forums.swift.org/u/ibex)\
**Post date:** [June 24, 2026, 12:59am UTC](https://forums.swift.org/t/the-perfect-follow-up-to-dictionary-performance-mapkeyedvalues-se-0510/87602/2 "2026-06-24T00:59:19Z")

</div>

[SE-0510](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0510-dictionary-mapvalues-with-keys.md) is still using the name `mapValuesWithKeys`, despite this:

> [@\[Accepted with modifications\]: SE-0510: Dictionary mapValuesWithKeys](https://forums.swift.org/t/accepted-with-modifications-se-0510-dictionary-mapvalueswithkeys/85124/1):
>
> One commenter pointed out that because the arguments to the closure body are (Key, Value), the name `mapKeyedValues` may be more clear at the use site. The LSG agrees with this, and has decided to accept this alternative name.  
> ...  
> Our decision is that the proposal should be **accepted with those modifications**. Thanks to everyone for your participation in the review.
> 
> – Steve Canon

`mapKeyedValues` or `mapValuesWithKeys`?

@scanon, @taylorswift: which one?

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [June 24, 2026, 1:12am UTC](https://forums.swift.org/t/the-perfect-follow-up-to-dictionary-performance-mapkeyedvalues-se-0510/87602/3 "2026-06-24T01:12:19Z")

</div>

It's supposed to be `mapKeyedValues`, but it doesn't look like it has shipped with Xcode 27b2 yet, so I can't confirm.

---

<div class="post-metadata">

**Author:** ![scanon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/scanon/32/2445_2.png) [@scanon](https://forums.swift.org/u/scanon)\
**Post date:** [June 24, 2026, 1:21pm UTC](https://forums.swift.org/t/the-perfect-follow-up-to-dictionary-performance-mapkeyedvalues-se-0510/87602/4 "2026-06-24T13:21:05Z")

</div>

`mapKeyedValues`.

The implementation PR is still open; Nate and Alex requested changes two weeks ago, which I think @taylorswift has made, so we should be pretty close to landing it.
