-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Struct containing a StructArray is not type stable #125
Comments
I was able to fix the type stability by specifying the full very verbose type in the struct definition. Is there any more compact alternative?
|
You need your field to be concrete so this isn't very surprising. You can write it as
|
Yeah I guess that makes sense. My mistake was incorrectly thinking that StructArray{Foo} was a concrete type. |
Maybe not relevant, but I came across this and found typeof(StructArray(YourType[])) as an easy way to get the concrete type. |
After converting my project to use StructArrays, I was surprised to see that there are now millions of allocations. The culprit seems to be a type instability with StructArrays, which causes some functions like
searchsorted
to allocate:The text was updated successfully, but these errors were encountered: