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
extendDeepNoArrays
includes by reference (i.e. does NOT deep-copy) typed arrays. Initially it looked as though the definition ofisArray
needs to be changed tobecause
Array.isArray
returnsfalse
for typed arrays.But it turned out that even the plain
extendDeep
already didn't deep-copy TYPED arrays. Therefore it was sufficient to add test coverage to ensure thatextendDeepNoArrays
doesn't deep-copy the typed arrays.An additional commit locks in the current, untested
extendDeep
behavior with typed arrays. However it's contentious because maybe the reason for thisextendDeep
behavior is that perhaps theplotly.js
doesn't use expect typed arrays (expects UNtyped arrays expressly or by implication). There are some good arguments for the benefits of the currentextendDeep
behavior 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 currentextendDeep
behavior. It means that for performance critical code sections that would use typed array, theplotly.js
contributor 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
extendDeepNoArrays
doesn't deep copy typed arrays (first commit) as there's a WebGL plot performance improvement that hinges on it.