Python Random vs. Cython C Rand for Dice Rolls
Steven D'Aprano
steve at pearwood.info
Sun Jun 7 14:33:16 EDT 2015
On Mon, 8 Jun 2015 03:17 am, C.D. Reimer wrote:
> Greetings,
>
> I've revisited my misbegotten childhood by translating the programs from
> "BASIC Computer Games" by David H. Ahl into Python. This is mostly an
> exercise in unraveling spaghetti code with all those GOTO statements
> going all over the place. The dice program caught my attention in
> particular for a stripped down version in Python and Cython to test the
> random number generator functionality.
>
> http://www.atariarchives.org/basicgames/showpage.php?page=57
>
> Here are my scripts to roll a pair of dice 50,000,000 times (this number
> creates a noticeable delay on my 3GHz quad processor). The Python script
> uses random, the Cython script uses C rand. Besides the obvious speed
> difference, the results are quite different.
C rand is not even close to random. The technical term for it is "shite".
--
Steve
More information about the Python-list
mailing list