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


Groups > comp.lang.python > #92333 > unrolled thread

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

Started byJeremy Sanders <jeremy@jeremysanders.net>
First post2015-06-08 09:43 +0200
Last post2015-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.


Contents

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

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

FromJeremy Sanders <jeremy@jeremysanders.net>
Date2015-06-08 09:43 +0200
SubjectRe: 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web