-
-
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
Improvement needed for inplace arithmetics #3424
Comments
Well, now that this issue is getting filed about once a month (#3217) we may finally be forced to do something about it. To me Maybe |
Sure, Obviously, x = [1, 2]
x[] = 10 # ==> [10, 2]
x[] += 10 # ==> [20, 2] |
is almost as fast as |
|
What about using
|
|
My intent with |
Thanks for clarifying! |
In current behavior, One can write
|
How about making e.g.
invoke
instead of
I get a feeling that with Jeff's work on overloading |
Thinking a little more about it, I guess that the first argument would have to be the actual function (e.g.
That would also mean that invocations of |
this looks like a better candidate for "Arraymaddon" (perhaps cross-ref to #5117) |
This should be closed by #17623, at which point |
Can you do e.g. Just noticed @toivoh's comment in #3424 (comment) is scarily similar to what I did in https://github.com/KristofferC/UpdateIndex.jl. |
@KristofferC, yes you can do |
Or, sorry, no, |
Will be addressed by #17623, which is on 0.6 already. |
This is likely to be never though, right? Are we giving up on a nice syntax to update just a part of an array? |
I still think this is addressed by the broadcast changes since the LHS of |
@StefanKarpinski, |
|
Note to future readers: nowadays, we indeed have a |
Following is a simple benchmark on inplace addition:
The Julia expressions in
add2!
andadd3!
are way too slow than they should be. I write several functions likeadd!
,sub!
, andmul!
inMLBase.jl
as a stopgap. However, I believe Julia itself should provide an efficient & concise way to do this, instead of forcing people to write loops whenever they want to add a matrix to another.What about introducing a bunch of inplace arithmetic functions such as
add!
,subtract!
,multiply!
, etc into Base?The text was updated successfully, but these errors were encountered: