# Standard Library

**URL:** https://forums.swift.org/c/development/stdlib/19.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [About the Standard Library category](https://forums.swift.org/t/about-the-standard-library-category/7456)

<div class="topic-metadata">

**Author:** [@Nicole\_Jacque](https://forums.swift.org/u/Nicole_Jacque)\
**Replies:** 0

</div>

For developers to discuss the implementation of the Swift standard library. This category will accept email sent to: swift+stdlib@forums.swift.org

---

## [Array.map lacks auto-vectorisation](https://forums.swift.org/t/array-map-lacks-auto-vectorisation/90500)

<div class="topic-metadata">

**Author:** [@k.benua](https://forums.swift.org/u/k.benua)\
**Replies:** 7\
**Last updated:** [November 6, 2026, 12:21pm UTC](https://forums.swift.org/t/array-map-lacks-auto-vectorisation/90500 "2026-11-06T12:21:52Z")

</div>

Introduction Recently I was profiling my app and was amazed, that this code @inline(never) func xorMap(\_ bytes: \[UInt8\], salt: UInt8) -\> \[UInt8\] { bytes.map { $0 ^ salt } } is not vectorised by compiler: in compile…

---

## [Request for review: small Codable documentation fix (#76329)](https://forums.swift.org/t/request-for-review-small-codable-documentation-fix-76329/90251)

<div class="topic-metadata">

**Author:** [@AliMark71](https://forums.swift.org/u/AliMark71)\
**Replies:** 0\
**Last updated:** [October 24, 2026, 9:20am UTC](https://forums.swift.org/t/request-for-review-small-codable-documentation-fix-76329/90251 "2026-10-24T09:20:04Z")

</div>

Hi all, I’m looking for guidance on the right reviewer for swiftlang/swift#76329, a small documentation-only change correcting parameter comments for three DecodingError functions in Codable.swift. The PR has been open…

---

## [AttributedContainer.init Performance Issues](https://forums.swift.org/t/attributedcontainer-init-performance-issues/89706)

<div class="topic-metadata">

**Author:** [@k.benua](https://forums.swift.org/u/k.benua)\
**Replies:** 2\
**Last updated:** [September 23, 2026, 9:11pm UTC](https://forums.swift.org/t/attributedcontainer-init-performance-issues/89706 "2026-09-23T21:11:58Z")

</div>

Current state of AttributedContainer.init Performance My team and I have faced unexpected degradation when performed migration to UIButton.Configuration with a AttributedString. At first, I've logged the duration locally…

---

## [Any Copyable vs Any](https://forums.swift.org/t/any-copyable-vs-any/88993)

<div class="topic-metadata">

**Author:** [@joehink](https://forums.swift.org/u/joehink)\
**Replies:** 1\
**Last updated:** [August 16, 2026, 5:06am UTC](https://forums.swift.org/t/any-copyable-vs-any/88993 "2026-08-16T05:06:18Z")

</div>

Is there any difference between a any Copyable type and a Any? Is it represented differently at runtime?

---

## [Performance improvements of migrating to \`MutableSpan\` in stdlib algorithms?](https://forums.swift.org/t/performance-improvements-of-migrating-to-mutablespan-in-stdlib-algorithms/88644)

<div class="topic-metadata">

**Author:** [@vanvoorden](https://forums.swift.org/u/vanvoorden)\
**Replies:** 12\
**Last updated:** [July 31, 2026, 9:54pm UTC](https://forums.swift.org/t/performance-improvements-of-migrating-to-mutablespan-in-stdlib-algorithms/88644 "2026-07-31T21:54:18Z")

</div>

The current implementation of Sequence.reversed() creates a new Array from the Sequence and swaps the elements of that Array: This is pretty simple and this makes sense. From more modern runtimes we might be able to …

---

## [Async{Throwing}Stream reimplementation](https://forums.swift.org/t/async-throwing-stream-reimplementation/85359)

<div class="topic-metadata">

**Author:** [@NotTheNHK](https://forums.swift.org/u/NotTheNHK)\
**Replies:** 24\
**Last updated:** [July 28, 2026, 6:32pm UTC](https://forums.swift.org/t/async-throwing-stream-reimplementation/85359 "2026-07-28T18:32:33Z")

</div>

Good day everyone, I’ve been working on a reimplementation of Async{Throwing}Stream for the past couple of weeks and would like to hear your thoughts and feedback before I proceed further. Here’s a summary of the chang…

---

## [RegexBuilder infinite loop when nullable capture starts with NegativeLookahead](https://forums.swift.org/t/regexbuilder-infinite-loop-when-nullable-capture-starts-with-negativelookahead/87713)

<div class="topic-metadata">

**Author:** [@ekassos](https://forums.swift.org/u/ekassos)\
**Replies:** 1\
**Last updated:** [June 26, 2026, 2:37pm UTC](https://forums.swift.org/t/regexbuilder-infinite-loop-when-nullable-capture-starts-with-negativelookahead/87713 "2026-06-26T14:37:41Z")

</div>

In Swift 6.4 or later, a RegexBuilder pattern can hang when an unbounded quantifier repeats a body that can match the empty string, where that body begins with NegativeLookahead. I've opened a corresponding issue and PR…

---

## [\`MutableSpan\` comes with performance penalties compared to \`UnsafePointer\`s](https://forums.swift.org/t/mutablespan-comes-with-performance-penalties-compared-to-unsafepointer-s/87385)

<div class="topic-metadata">

**Author:** [@MahdiBM](https://forums.swift.org/u/MahdiBM)\
**Replies:** 17\
**Last updated:** [June 24, 2026, 1:46pm UTC](https://forums.swift.org/t/mutablespan-comes-with-performance-penalties-compared-to-unsafepointer-s/87385 "2026-06-24T13:46:31Z")

</div>

Mostly to redirect some eyes to this issue: Don't impose a performance penalty when using \`MutableSpan\` · Issue #89954 · swiftlang/swift · GitHub What happened is that I created this PR, and there I noticed usage of Mut…

---

## [Faster shuffles with batching](https://forums.swift.org/t/faster-shuffles-with-batching/85503)

<div class="topic-metadata">

**Author:** [@Nevin](https://forums.swift.org/u/Nevin)\
**Replies:** 15\
**Last updated:** [April 27, 2026, 3:12pm UTC](https://forums.swift.org/t/faster-shuffles-with-batching/85503 "2026-04-27T15:12:38Z")

</div>

Last year, Daniel Lemire and I published a paper where we showed that batched dice rolling can make array shuffles several times faster: \[2408.06213\] Batched Ranged Random Integer Generation Our C implementation was gen…

---

## [Publishing stdlib documentation on swift.org](https://forums.swift.org/t/publishing-stdlib-documentation-on-swift-org/85542)

<div class="topic-metadata">

**Author:** [@invalidname](https://forums.swift.org/u/invalidname)\
**Replies:** 8\
**Last updated:** [April 3, 2026, 7:33pm UTC](https://forums.swift.org/t/publishing-stdlib-documentation-on-swift-org/85542 "2026-04-03T19:33:26Z")

</div>

We’re happy to share that we’re working on bringing documentation for the Swift standard library to Swift.org. Purpose and impact: With this change, you’ll be able to browse documentation for the Swift standard library …

---

## [Are stdlib modules built with dynamic exclusivity checking enabled?](https://forums.swift.org/t/are-stdlib-modules-built-with-dynamic-exclusivity-checking-enabled/81495)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 1\
**Last updated:** [March 12, 2026, 1:44pm UTC](https://forums.swift.org/t/are-stdlib-modules-built-with-dynamic-exclusivity-checking-enabled/81495 "2026-03-12T13:44:22Z")

</div>

the question is essentially the title: are stdlib targets themselves built with the runtime exclusivity checks on or off? i've found a number of references in GitHub search that suggest at least some stdlib code is opted…

---

## [Improving Type Name Computation Performance](https://forums.swift.org/t/improving-type-name-computation-performance/85076)

<div class="topic-metadata">

**Author:** [@k.benua](https://forums.swift.org/u/k.benua)\
**Replies:** 9\
**Last updated:** [March 3, 2026, 6:21am UTC](https://forums.swift.org/t/improving-type-name-computation-performance/85076 "2026-03-03T06:21:32Z")

</div>

Improving Type Name Computation Performance Introduction The recommended way to obtain a type name from a generic type parameter is: String(describing: type(of:)) — returns the type name without the module prefix S…

---

## [SE-0489 followup: DecodingError.valueNotFound mentions null, which is not always right](https://forums.swift.org/t/se-0489-followup-decodingerror-valuenotfound-mentions-null-which-is-not-always-right/84844)

<div class="topic-metadata">

**Author:** [@ZevEisenberg](https://forums.swift.org/u/ZevEisenberg)\
**Replies:** 5\
**Last updated:** [February 23, 2026, 10:52pm UTC](https://forums.swift.org/t/se-0489-followup-decodingerror-valuenotfound-mentions-null-which-is-not-always-right/84844 "2026-02-23T22:52:48Z")

</div>

In SE-0489: Improve EncodingError and DecodingError's printed descriptions, improved the debug descriptions of DecodingError. In particular, the debug description for DecodingError.valueNotFound is now: "DecodingError.v…

---

## [Slow regex performance](https://forums.swift.org/t/slow-regex-performance/75768)

<div class="topic-metadata">

**Author:** [@sspringer](https://forums.swift.org/u/sspringer)\
**Replies:** 6\
**Last updated:** [February 16, 2026, 7:39pm UTC](https://forums.swift.org/t/slow-regex-performance/75768 "2026-02-16T19:39:50Z")

</div>

The application of regex expressions in Swift seems to be quite slow e.g. in comparison to Java, what is the issue here? With a small test for Swift and the according small test for Java the numbers are: Java: ... (12…

---

## [On unifying the Async{Throwing}Stream internal implementation](https://forums.swift.org/t/on-unifying-the-async-throwing-stream-internal-implementation/84737)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 6\
**Last updated:** [February 16, 2026, 12:21pm UTC](https://forums.swift.org/t/on-unifying-the-async-throwing-stream-internal-implementation/84737 "2026-02-16T12:21:05Z")

</div>

per your suggestion here @FranzBusch, i did a brief investigation of how the async stream variants might be refactored so they share more internal logic, and wanted to document my findings thus far (messy draft PR here). …

---

## [Should AsyncStream terminate if its continuation goes out of scope?](https://forums.swift.org/t/should-asyncstream-terminate-if-its-continuation-goes-out-of-scope/84669)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 11\
**Last updated:** [February 13, 2026, 5:42am UTC](https://forums.swift.org/t/should-asyncstream-terminate-if-its-continuation-goes-out-of-scope/84669 "2026-02-13T05:42:20Z")

</div>

as i've had AsyncStream termination on the mind recently, it occurred to me that if a stream's continuation "goes out of scope", it becomes impossible to terminate iteration by any means other than task cancellation (ass…

---

## [Proposed change to AsyncStream termination logic](https://forums.swift.org/t/proposed-change-to-asyncstream-termination-logic/84637)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 8\
**Last updated:** [February 10, 2026, 4:48pm UTC](https://forums.swift.org/t/proposed-change-to-asyncstream-termination-logic/84637 "2026-02-10T16:48:21Z")

</div>

as surfaced in this thread, the current implementation of AsyncStream termination via cancellation is not strictly 'atomic' – the termination handler can run before the stream's internal state has been updated to clear o…

---

## [Should we document the behavior of \`Mutex.withLockIfAvailable()\`?](https://forums.swift.org/t/should-we-document-the-behavior-of-mutex-withlockifavailable/83166)

<div class="topic-metadata">

**Author:** [@grynspan](https://forums.swift.org/u/grynspan)\
**Replies:** 9\
**Last updated:** [January 20, 2026, 11:40pm UTC](https://forums.swift.org/t/should-we-document-the-behavior-of-mutex-withlockifavailable/83166 "2026-01-20T23:40:18Z")

</div>

The documentation for Mutex.withLockIfAvailable() does not specify if it can spuriously fail to acquire the mutex. I'd like to get feedback from the community: should we make clear that it cannot fail in this fashion? T…

---

## [Possible unsoundness with RawSpan and MutableRawSpan](https://forums.swift.org/t/possible-unsoundness-with-rawspan-and-mutablerawspan/83980)

<div class="topic-metadata">

**Author:** [@ellie20](https://forums.swift.org/u/ellie20)\
**Replies:** 11\
**Last updated:** [January 16, 2026, 12:25am UTC](https://forums.swift.org/t/possible-unsoundness-with-rawspan-and-mutablerawspan/83980 "2026-01-16T00:25:13Z")

</div>

The RawSpan and MutableRawSpan APIs make it possible to arbitrarily change the bit pattern of a BitwiseCopyable value without using unsafe code. For example, the following function returns a Bool value with an invalid bi…

---

## [Preferred approach for testing internal logic](https://forums.swift.org/t/preferred-approach-for-testing-internal-logic/84010)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 0\
**Last updated:** [January 7, 2026, 3:10pm UTC](https://forums.swift.org/t/preferred-approach-for-testing-internal-logic/84010 "2026-01-07T15:10:59Z")

</div>

i was investigating writing some tests for an internal type within the Runtime module, and found my desired strategy of doing @internal import Runtime unfortunately did not work. i first got a number of complaints about …

---

## [Back-deployment of SE-0472 \`Task.immediate\`?](https://forums.swift.org/t/back-deployment-of-se-0472-task-immediate/81576)

<div class="topic-metadata">

**Author:** [@pyrtsa](https://forums.swift.org/u/pyrtsa)\
**Replies:** 7\
**Last updated:** [December 30, 2025, 9:32am UTC](https://forums.swift.org/t/back-deployment-of-se-0472-task-immediate/81576 "2025-12-30T09:32:42Z")

</div>

Is there any chance of back-deploying the new Task.immediate(name:priority:operation:)functions to older Apple platform versions than 26? The functionality introduced in SE-0472 is key to avoiding initial delays with as…

---

## [Nested InlineArray generates unnecessary copies](https://forums.swift.org/t/nested-inlinearray-generates-unnecessary-copies/83364)

<div class="topic-metadata">

**Author:** [@tgu](https://forums.swift.org/u/tgu)\
**Replies:** 3\
**Last updated:** [November 22, 2025, 11:12am UTC](https://forums.swift.org/t/nested-inlinearray-generates-unnecessary-copies/83364 "2025-11-22T11:12:05Z")

</div>

Hi, I was playing around with InlineArray and found out that this function func col(i: Int, v: InlineArray\<8, InlineArray\<10, Int\>\>) -\> InlineArray\<10, Int\> { \[v\[i\]\[0\], v\[i\]\[1\], v\[i\]\[2\], v\[i\]\[3\], v\[i\]\[4\], v\[i…

---

## [String.replacing performance](https://forums.swift.org/t/string-replacing-performance/68679)

<div class="topic-metadata">

**Author:** [@danielpunkass](https://forums.swift.org/u/danielpunkass)\
**Replies:** 6\
**Last updated:** [November 17, 2025, 2:43pm UTC](https://forums.swift.org/t/string-replacing-performance/68679 "2025-11-17T14:43:26Z")

</div>

Recently, upon spotting a use of Regex in the wild to achieve the equivalent of a literal string replacement, I wondered about the performance implications of using Regex this way. To my surprise, I learned that using S…

---

## [Purpose of std::atomic in WeakReference](https://forums.swift.org/t/purpose-of-std-atomic-in-weakreference/83180)

<div class="topic-metadata">

**Author:** [@corscheg](https://forums.swift.org/u/corscheg)\
**Replies:** 1\
**Last updated:** [November 13, 2025, 1:19am UTC](https://forums.swift.org/t/purpose-of-std-atomic-in-weakreference/83180 "2025-11-13T01:19:54Z")

</div>

Hello! I’m exploring the runtime source code now, and I can’t figure out why std::atomic is needed in WeakReferenceclass. The comment at the top of the file states: // Thread-safety: // // Reading a weak reference must…

---

## [SE-0489 followup: formatting EncodingError and DecodingError's debug descriptions](https://forums.swift.org/t/se-0489-followup-formatting-encodingerror-and-decodingerrors-debug-descriptions/81433)

<div class="topic-metadata">

**Author:** [@ZevEisenberg](https://forums.swift.org/u/ZevEisenberg)\
**Replies:** 13\
**Last updated:** [August 8, 2025, 11:22pm UTC](https://forums.swift.org/t/se-0489-followup-formatting-encodingerror-and-decodingerrors-debug-descriptions/81433 "2025-08-08T23:22:31Z")

</div>

Hi all! In the acceptance post for SE-0489: Improve EncodingError and DecodingError's printed descriptions, @xwu requested: To that end, here's a thread where we can talk about it! If you're coming from the original re…

---

## [Assessing Performance Impact on the Runtime](https://forums.swift.org/t/assessing-performance-impact-on-the-runtime/81506)

<div class="topic-metadata">

**Author:** [@compnerd](https://forums.swift.org/u/compnerd)\
**Replies:** 0\
**Last updated:** [August 5, 2025, 4:37pm UTC](https://forums.swift.org/t/assessing-performance-impact-on-the-runtime/81506 "2025-08-05T16:37:14Z")

</div>

I am looking for some help identifying a reasonable a good mechanism for measuring the performance impact of some changes that I am toying around for the runtime on Windows. Given the previously shared plan for Windows …

---

## [Use of \`Mutex\` within the stdlib's \`Concurrency\` module](https://forums.swift.org/t/use-of-mutex-within-the-stdlibs-concurrency-module/81191)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 9\
**Last updated:** [July 22, 2025, 4:49pm UTC](https://forums.swift.org/t/use-of-mutex-within-the-stdlibs-concurrency-module/81191 "2025-07-22T16:49:56Z")

</div>

i was looking into a bit of refactoring within some existing stdlib code within the Concurrency module, and was wondering if the Mutex type is usable in that context. the relevant method has an availability annotation of…

---

## [How necessary is @lifetime(borrow pointer) on init of MutableRawSpan (etc.)?](https://forums.swift.org/t/how-necessary-is-lifetime-borrow-pointer-on-init-of-mutablerawspan-etc/81077)

<div class="topic-metadata">

**Author:** [@carlos42421](https://forums.swift.org/u/carlos42421)\
**Replies:** 3\
**Last updated:** [July 16, 2025, 9:03pm UTC](https://forums.swift.org/t/how-necessary-is-lifetime-borrow-pointer-on-init-of-mutablerawspan-etc/81077 "2025-07-16T21:03:16Z")

</div>

Hiya, Those of you who know me know that I like to build my own variant stdlib for my platform. This mostly works well, but sometimes the tight coupling to the compiler trips me up when I update. This time, I've copied…

---

## [A bug with \`Optional\` in Swift 6.2](https://forums.swift.org/t/a-bug-with-optional-in-swift-6-2/80955)

<div class="topic-metadata">

**Author:** [@Filozoff](https://forums.swift.org/u/Filozoff)\
**Replies:** 6\
**Last updated:** [July 8, 2025, 5:08am UTC](https://forums.swift.org/t/a-bug-with-optional-in-swift-6-2/80955 "2025-07-08T05:08:03Z")

</div>

Hey guys! When switching from Swift 6.0 to new Swift version 6.2 (bundled with Xcode 26 beta 2) I noticed a weird error: \<unknown\>:0: error: lifetime-dependent variable '$implicit\_value' escapes its scope Screenshot b…

[Next page](https://forums.swift.org/c/development/stdlib/19.md?page=1)
