-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
PERF: Prevent using copy in astype if not needed #4575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sometimes the copy will have been intentional. Should we merely hope that On 12 April 2015 at 08:14, Joerg Rings notifications@github.com wrote:
|
So far, the only instances I replaced were those where a variable was
|
Depends if it is then modified (and not part of the output, which is almost On 12 April 2015 at 12:48, Joerg Rings notifications@github.com wrote:
|
I think that when the copy is intended, it should be made explicit with: from sklearn.utils.fixes import astype
...
X = astype(X, dtype, copy=True) |
+1 for always using the version from fixes. On 13 April 2015 at 04:36, Olivier Grisel notifications@github.com wrote:
|
@jrings why would assigning it to the same variable be related to whether a copy was intentional? The question is whether we overwrite data that the user passed in and that the user might expect to be usable afterwards. |
Fails on python3 on sparse matrices? |
It's not related to Python 3, it fails because the last job is on recent versions of numpy were |
Ahhh... right, makes sense. |
So based on the discussion from #4585, we should:
@jrings are you interested in tacking this or would you like someone else to take over this PR? |
BTW the above means that we should extend |
I'll take a look on the weekend, I should have time, if not I'll let you On Fri, Apr 24, 2015 at 11:02 AM, Olivier Grisel notifications@github.com
|
Thanks. |
I'm just gonna start over from a fresh branch off master and do a separate PR since I messed up the first attempts...is that ok? |
Actually, I don't think I'll be able to find time, a had a quick look yesterday but won't have more time and have to work on something else today. So if someone wants to jump in? |
taken over by #4645 closing. |
I went over all instances of
astype
in the code and, if a copy was not needed because it was assigned back to the same variable, usedutils.fixes.astype
withcopy=False
.Resolves #4573