Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92333

Re: Python Random vs. Cython C Rand for Dice Rolls

From Jeremy Sanders <jeremy@jeremysanders.net>
Subject Re: Python Random vs. Cython C Rand for Dice Rolls
Date 2015-06-08 09:43 +0200
References <55747C96.7090006@cdreimer.com>
Newsgroups comp.lang.python
Message-ID <mailman.292.1433749393.13271.python-list@python.org> (permalink)

Show all headers | View raw


C.D. Reimer wrote:

> Is there something in the Cython code that I need to change and/or find
> a better C random number generator?

This may not be helpful, but numpy is pretty helpful for this sort of thing:

import numpy
import numpy.random

a=numpy.random.randint(1,6,50000000)
b=numpy.random.randint(1,6,50000000)

numpy.bincount(a+b-1)

array([      0, 1999229, 4000369, 5999372, 7999232, 9998769, 8003430,
       5998538, 4001160, 1999901])

This takes a few seconds on my system.

Jeremy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python Random vs. Cython C Rand for Dice Rolls Jeremy Sanders <jeremy@jeremysanders.net> - 2015-06-08 09:43 +0200

csiph-web