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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'numpy': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Cython': 0.16; 'wrote:': 0.16; 'import': 0.24; 'skip:b 30': 0.24; 'sort': 0.25; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'helpful': 0.27; 'random': 0.29; 'seconds': 0.31; 'code': 0.31; 'to:addr:python-list': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'system.': 0.39; 'takes': 0.39; 'received:de': 0.40; 'subject:. ': 0.66; 'received:130': 0.75; 'from:addr:jeremy': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Jeremy Sanders <jeremy@jeremysanders.net>
Subject Re: Python Random vs. Cython C Rand for Dice Rolls
Date Mon, 08 Jun 2015 09:43:33 +0200
References <55747C96.7090006@cdreimer.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host lap75107.mpe.mpg.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.292.1433749393.13271.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1433749393 news.xs4all.nl 2900 [2001:888:2000:d::a6]:40466
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:92333

Show key headers only | 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