You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think even a maximum dynamic dimensionality representable by u8 (256) would never be used anywhere since the element number grows exponentially with the dimensionality and even 2^100 < 2^128 (representable by u7) bytes memory usage is already really out of bounds.
The idea to use another data structure than Vec sounds also good since Vec offers much more flexibility (growing and shrinking) that is not required at all. Even a Box<[usize]> would be a better fit.
Using SmallVec has the advantage of having no dyn memory alloc up to a certain size but with this approach we could model the whole entirety of Ix and besides that SmallVec is again growable and shrinkable. Better would be a SmallBoxedSlice which does not exist, ... yet.
This is supported right now. I agree it's pointless. In this case all dimensions are 1, so the len of the array is 1 element, even if it has 1 << 16 axes.
Array::zeros(vec![1;1 << 16])
I'd like to do a custom implementation here, SmallVec for example is too bulky, would not be a big gain.
Activity
Robbepop commentedon Mar 28, 2017
I think even a maximum dynamic dimensionality representable by
u8
(256) would never be used anywhere since the element number grows exponentially with the dimensionality and even 2^100 < 2^128 (representable byu7
) bytes memory usage is already really out of bounds.The idea to use another data structure than
Vec
sounds also good sinceVec
offers much more flexibility (growing and shrinking) that is not required at all. Even aBox<[usize]>
would be a better fit.Using
SmallVec
has the advantage of having no dyn memory alloc up to a certain size but with this approach we could model the whole entirety ofIx
and besides thatSmallVec
is again growable and shrinkable. Better would be aSmallBoxedSlice
which does not exist, ... yet.bluss commentedon Mar 28, 2017
This is supported right now. I agree it's pointless. In this case all dimensions are 1, so the len of the array is 1 element, even if it has 1 << 16 axes.
I'd like to do a custom implementation here, SmallVec for example is too bulky, would not be a big gain.
Robbepop commentedon Mar 28, 2017
Yeah it is a real edge case but for a general approach you may be right!