Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92333 > unrolled thread
| Started by | Jeremy Sanders <jeremy@jeremysanders.net> |
|---|---|
| First post | 2015-06-08 09:43 +0200 |
| Last post | 2015-06-08 09:43 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python Random vs. Cython C Rand for Dice Rolls Jeremy Sanders <jeremy@jeremysanders.net> - 2015-06-08 09:43 +0200
| From | Jeremy Sanders <jeremy@jeremysanders.net> |
|---|---|
| Date | 2015-06-08 09:43 +0200 |
| Subject | Re: Python Random vs. Cython C Rand for Dice Rolls |
| Message-ID | <mailman.292.1433749393.13271.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web