-
-
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
@threads in array comprehension #32000
Comments
Yes, this could be implemented even now by expanding to a It's difficult to support every feature of comprehensions though. Initially we could only do known-length iterators and cases where the result type is easy to determine. |
It surely would be a great feature even if, initially, it could only be done for simple cases. Array comprehensions are just so beautifully compact, and yet readable. Maybe then @threads could take a keyword argument e.g. something like
? |
In the Julia discourse thread someone brought up the topic of broadcast. I believe this could maybe be analogically done like this
assuming A and B are both arrays with 2 or more dimensions. |
See #19777 for |
Also maybe stuff like this would be very handy: y = sum(@threads f(x) for x in X) or at least the same syntax as for y = @threads (+) for x in X
f(x)
end Generally the syntax is not that important at all, the functionality is what matters here, I would say. |
FYI, with ThreadsX.jl you can do |
For multidimensional array comprehensions,
|
Is this still an issue? I see. a number of options discussed in the comments but no activity for around a year. Thanks. |
This is a feature suggestion. It would be nice it the @threads macro would work also inside array comprehensions as:
I.e. that example should produce the same result as:
Yet, currently it is not supported:
See the corresponding topic in Julia discourse.
The text was updated successfully, but these errors were encountered: