Improve the implementation of entries #4064
Draft
+114
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements functions
IM2_Matrix_get_entriesandIM2_MutableMatrix_get_entriesthat gives an array with all of the entries and uses these to implement entries. This fixes the quadratic in the number of rows behavior seen in #4016. Strictly this change is only needed forMatrixand notMutableMatrix, and I have not yet tested whether there is an improvement forMutableMatrix, since this version does involve an extra copy. Additionally, forMutableMatrixwe are still callingget_entryentry by entry on the matrix itself when we should in theory be able to loop over an array somewhere.There is a slight design compromise in this, as top level expects a list of lists, but it is not easy to return a list of lists from the interface level, we return just a single sequence and let the top level code rearrange that into a list of lists. This rearrangement could in theory happen at the "d" level, but it's not clear if that's faster.