-
Notifications
You must be signed in to change notification settings - Fork 432
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
Rng::iter #275
Rng::iter #275
Conversation
Which warnings?
We had an issue about it, dhardy#73, but not a lot of discussion. Personally I would not add any more character distributions besides |
To be honest I don't follow most of the code here, I know too little about iterators yet. @burdges, I think you are much more expert to review here. I imagined an iterator to do nothing more than repeatedly calling |
The old I guess we could make I don't know, but one significant advantage is that this "feels" like a lower-level iterator, i.e. on the RNG itself, despite the fact that we can't do that — but alternatively, we might be able to implement a streaming iterator I guess. |
I'm dubious about this reimplement standard iterator methods approach. I'm also confused what roll this plays: What are you trying to achieve? Are you wanting an Iterator that produces |
If you want an iterator that creates values of a type You want an iterator that returns |
The role this plays is to replace Good point about use of |
Rebased on top of #279. |
I like the But I am curious if there is a meaningful difference in the code they generate. Can you maybe do some benchmarks using both methods and a few different distributions ( |
Benchmarks show a significant improvement over the old
|
Wait... using I think the benchmark above is wrong: transmuting a slice presumably keeps the same length counter, but since Now I'm only confused why my iterator code is slightly faster than everything else including |
Updated benchmarks (here
|
One issue that may cause the lower numbers is rust-lang/rust#47062 (and rust-lang/rust#47665). So I first set That Benchmarks from my PC:
And the same, but now with HC-128 (because there
|
Very similar results with
I guess this means we should deprecate |
Add pseudo-iterator over RNGs
This is basically a copy from my old branch plus some doc/test tweaks, plus an extra comment about why we can't iterate over reference types directly (without redundant referencing — yes I tried).
gen_ascii_chars
— simple but requires deciding what kind of such distributions we want (e.g. something similar to regex range types?), which didn't happen yet.