-
Notifications
You must be signed in to change notification settings - Fork 424
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
Random's iterate() method: replace with iterator these()? #19603
Comments
For now, we should mark |
I agree that this issue's proposal is attractive, but believe it requires the ability to have follower iterators be able to know the total number of elements being iterated over rather than just their place in it so that they can advance the cursor. It may also require some sort of "We're all starting now" or "We're all done now" call so that the cursor can be advanced at a safe point (i.e., that other followers aren't going to read the old/new value at the wrong time). I view this as being fairly similar to #11428 |
I think a more modest (and hopefully easy to achieve) proposal would be to simply make We could certainly create a Of course I think it is good to do those leader/follower improvements - I am just not so sure we want to tie the Random module stability to them. |
Unless I've missed something, I don't think an |
Good point. I think it would work if the |
Yeah, that's definitely the easier case (e.g., bump the cursor by the number of indices after all the tasks the leader created have completed). |
Riffing on the context manager, we could have loops (including zippered loops) call |
Random is no longer intended for 2.0, removing the tag |
Making a note that #24379 replaced In stabilization discussions, there was still a desire to eventually support an
|
Closing in favor of #10717, since this is essentially a duplicate issue. |
see also / is this a duplicate of #10717 ?
Can/should we replace
PCGRandomStream.iterate()
method with the iteratorthese()
? Having athese
iterator is more natural.Background:
iterate()
yields a random number for every index in a domain that's passed to it as an argument.iterate(D)
advances the generator state byD.size
immediately, before yielding any values. IfD
is distributed, each locale/task effectively gets its own private copy of the random number generator that starts at an appropriate offset.In other words,
iterate()
is likefillRandom()
, except it yields instead of updating an array element. In fact,fillRandom(A)
is implemented by zipperingiterate(A.domain)
withA
.Ideally, instead of
forall i in iterate(D)
we would like to writeforall (_, i) in zip(D, myRNG)
. How to accomplish this? What leader/follower improvements, if any, does this require?The text was updated successfully, but these errors were encountered: