Repository navigation
Conversation
|
— codex on behalf of Ralf — Keep arrays of explicitly default-constructible elements compiling. The optimized branch accepts element types with an explicit default constructor because When resolving the conflict with master, please also carry forward the single-length indexed iteration from #6278 into the new loop. New loop Generated by Codex. Ralf has yet to review these findings. |
|
🤖 AI text below 🤖 Both points are valid. Explicit default constructor: Confirmed. Indexed iteration from #6278: Merged master in bb21b98. After the merge, |
Fill fixed-size arrays in place when the element type is default constructible and move assignable, instead of going through an index_sequence expansion of Size elements. A std::array<int, 102400> member took 135 s to compile with clang; it now takes 1.5 s. Fixes pybind#5765. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-fable-5-2
Assisted-by: ClaudeCode:claude-fable-5-2
0804cdb to
f36aef9
Compare
🤖 AI text below 🤖
Description
Fixes #5765.
array_casterloaded fixed-size arrays into a temporarystd::vector, then built the array with anindex_sequenceofSizeelements. That expansion is very slow to compile for large arrays: the example from the issue (std::array<int, 102400>) took 135 s with Apple clang 21 at-O1.If the element type is default constructible and move assignable, the caster now fills the array in place. Now the example compiles in 1.5 s. Other element types still use the old path. The array is assigned only after all elements load.
This removes the old comment that said one generic path compiles faster than specializations, because this issue shows the opposite for large
Size.Suggested changelog entry:
std::arraytypes withpybind11/stl.h.