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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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