Reading and decompressing a bunch of floats from a FileDescriptor, minimizing copies

There are WWDC talks which explain how to use them, but yes, overall the documentation is kind of weak. I think the reason that is the case is because we're reluctant to present the unsafe APIs as a solution for this kind of problem. It's very much an experts-only tool and we don't want to advertise it like everybody should immediately reach for UnsafeBufferPointer.

Long-term, Span<T> and RawSpan (pitch) are designed to support these kinds of things in a safe, convenient way. I expect there will probably be a greater investment in documenting how to use them for processing binary data.

3 Likes