Skip to content

[Question] Parallelizing over a list of PyArrays with rayon #363

Answered by adamreichold
jatentaki asked this question in Q&A
Discussion options

You must be logged in to vote

are those structs all just holding references or am I copying big arrays of input data?

You are just copying references, not the underlying data.

Is there a better way to achieve my goal?

The problem when using Rayon here is that PyReadonlyArray<'py, T, D>: !Send as it basically wraps a &'py PyArray<T, D> which is not Send either as it is locked to the lifetime 'py for which the GIL is held by the current thread.

At the moment I don't see a better way to achieve what you need. I suspect that the overhead of the three calls to collect should be manageable if what you are doing instead of cumsum is sufficiently expensive.

One alternative that would however require a different signature …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@adamreichold
Comment options

Answer selected by jatentaki
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #362 on December 22, 2022 22:28.