Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:

Can you describe more about your use-case for this?

You can already do something like this now with something like the following:

    def random_subset(sequence):
        source = random.randbytes(len(sequence))
        return [x for x, r in zip(sequence, source) if r & 1]

You could add a random.shuffle() call at the end if your application needs it.

For the case with counts, you could do getrandbits(i).bit_count() to get a 
binomial distribution to choose how many of each element to include.

----------
components: +Library (Lib) -Extension Modules
nosy: +Dennis Sweeney, rhettinger
versions: +Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46190>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to