Skip to content

Build rows without splatting when feasible - #376

Open
aplavin wants to merge 1 commit into
perf_widefrom
wide_rows
Open

aplavin wants to merge 1 commit into
perf_widefrom
wide_rows

Conversation

@aplavin

@aplavin aplavin commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Splatting more than 32 values into createinstance allocates. For row types whose createinstance belongs to StructArrays or StaticArrays, build the row from the tuple of field values directly.
Gets to zero allocations in operations like nt[1] / pop!(nt) / sum(r -> r.x1, nt) / ... for wide eltypes.

Compared to #358: applies to both getindex, pop! and popfirst!, and to both tuples/namedtuples and staticarrays types.
For custom structs, would need change to createinstance API that is public and already overloaded in other packages, so not doing that here. Very wide custom structs are quite rare anyways.

Splatting more than 32 values into `createinstance` allocates. For row types whose `createinstance` belongs to StructArrays or StaticArrays, build the row from the tuple of field values directly. Applies to scalar `getindex`, `pop!` and `popfirst!`.

Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant