Ensure that extendDeepNoArrays includes typed arrays by reference #866
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.
These changes ensure that
extendDeepNoArraysincludes by reference (i.e. does NOT deep-copy) typed arrays. Initially it looked as though the definition ofisArrayneeds to be changed tobecause
Array.isArrayreturnsfalsefor typed arrays.But it turned out that even the plain
extendDeepalready didn't deep-copy TYPED arrays. Therefore it was sufficient to add test coverage to ensure thatextendDeepNoArraysdoesn't deep-copy the typed arrays.An additional commit locks in the current, untested
extendDeepbehavior with typed arrays. However it's contentious because maybe the reason for thisextendDeepbehavior is that perhaps theplotly.jsdoesn't use expect typed arrays (expects UNtyped arrays expressly or by implication). There are some good arguments for the benefits of the currentextendDeepbehavior when it comes to handling user-supplied typed-array input - e.g. typed arrays generally indicate performance awareness, therefore the user can reasonably expect structure sharing internally. It would make sense to treat typed arrays as atomic values, which is the currentextendDeepbehavior. It means that for performance critical code sections that would use typed array, theplotly.jscontributor has to bear in mind that typed arrays are included by reference.If the second commit isn't timely, I'm glad to reset it, but even in that case it's useful to ensure that
extendDeepNoArraysdoesn't deep copy typed arrays (first commit) as there's a WebGL plot performance improvement that hinges on it.