MAINT: use copy=False in a few astype() calls#5909
Merged
jaimefrio merged 3 commits intonumpy:masterfrom May 22, 2015
Merged
Conversation
numpy/linalg/linalg.py
Outdated
Member
There was a problem hiding this comment.
Did you miss the copy=False here?
Contributor
Author
There was a problem hiding this comment.
There is no copy=False for astype of a numpy scalar, I think.
>>> import numpy as np
>>> np.float64(42).astype(float)
42.0
>>> np.float64(42).astype(float, copy=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: astype() takes no keyword arguments
Member
There was a problem hiding this comment.
Ah, I see... There also seem to be tests that would catch if someone tried to introduce that optimization in the future, so I guess it is OK.
Perhaps it is worth a comment? What about branching on np.isscalar(r)?
Contributor
Author
OK I've added this in the most recent commit. |
jaimefrio
added a commit
that referenced
this pull request
May 22, 2015
MAINT: use copy=False in a few astype() calls
Member
|
Merged, thanks! |
eric-wieser
added a commit
to eric-wieser/numpy
that referenced
this pull request
Nov 9, 2017
This takes numpygh-5909 a little further.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is like scikit-learn/scikit-learn#4573. I wasn't able to see any quantifiable speed or memory improvements.