Python: Using XOFs for general-purpose Random

As always, one's own stack overflow answers make the best blog posts. In this case, we craft a version of random.Random with a few modifications: Pulls its data from an arbitrary stream (in our case, a DRBG such as a hash function or deterministic CSPRNG) Wastes noticeably fewer bits when generating random integers Has fixed code for .shuffle, on the offchance CPython ever changes theirs, and to make it …