apilloud commented on a change in pull request #15912:
URL: https://github.com/apache/beam/pull/15912#discussion_r744013077
##########
File path: sdks/python/apache_beam/transforms/util.py
##########
@@ -725,7 +725,7 @@ class Reshuffle(PTransform):
"""
# We use 32-bit integer as the default number of buckets.
- _DEFAULT_NUM_BUCKETS = 1 << 32
+ _DEFAULT_NUM_BUCKETS = (1 << 32) - 1
Review comment:
https://github.com/python/cpython/blob/main/Lib/random.py
This effectively becomes `randint(0, (1 << 32) - 1)`
randint -> randrange(a, b+1) so we have `randrange(0, (1 << 32))`
For this case randrange(0, n) becomes _randbelow(n) so `_randbelow(1<<32)`
_randbelow(n) becomes getrandbits(n.bit_length()) so `_randbelow(33)`
Seems there is still an off by one error?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]