-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
unexpected failure to copy #3037
Comments
Doesn't this restrict future enhancements to eliminate temporary objects? I don't think we should force all operators to make copies. |
I think it was Stefan Karpinsky who commented in the discussion of some other issue (I can't find it now because the search on Github issues has disappeared today), that the type of return arguments shoud not depend on the value of inout arguments. Here it is not the type that changes but whether ^(X,k) is an inplace operation or not depends on the value of k. Elsewhere in Julia great care is taken to flag all inplace functions with !. Here it happens unexpectedly. If performance is the issue, then I would say anyone that cares about efficiency when raising big matrices to integer powers should be paying careful attention to what they are doing anyway and could easily just avoid calling ^(X,1) unnecessarily. On the other hand, if size and speed are not an issue then ^ should just work without surprizes. |
|
I agree with @bsxfan that this is just asking for trouble. |
I'm fine with adding a |
The current behavior is julia> is(a, a*1)
false
julia> is(a, a/1)
false
julia> is(a, a^1)
true For consistency, |
The unary - operator for numeric arrays creates as new array, but the unary + does not:
This may not be so bad, since the unary + is probably quite rare.
But the following unexpected failure to copy WILL cause a hard-to-find bug in someone's code at some stage:
Counterexample:
The text was updated successfully, but these errors were encountered: