Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.05; 'cc:addr:python-list': 0.10; 'python': 0.11; 'declaration,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Cython': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'space.': 0.22; 'am,': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message- id:@mail.gmail.com': 0.28; 'initialized': 0.29; 'array': 0.29; 'function': 0.30; 'values': 0.30; 'certainly': 0.31; 'values.': 0.33; 'definition': 0.34; 'received:google.com': 0.34; "isn't": 0.35; 'but': 0.36; 'responsible': 0.37; 'subject:: ': 0.37; 'where': 0.40; 'times': 0.61; 'total': 0.64; 'subject:. ': 0.66; 'chrisa': 0.84; 'to:none': 0.90 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Xel+U4JRXm+9qU9SsSJYtVYt05VeIirakBa5nqjU6bo=; b=sA+l5rr7n5IBRAQpO5LaqDSJb33wDikr9LuXx4wIEPR7WCrtKOqoZlhLjZ+nsQSC63 kofHNDUBwgBsFrm0j0y8RWFzyfp9OM+xh4ur2v62K5ro+fWyslY+Jzs9P6y57Wl5/UIa ltYhwBIvOZYWjLZJOINzQOQoblEjbXqlJ59O7w5Czke0EYjnT9gLGZeUFmmFtYA44Pcc U/1cg66e7tiaQH/al5cmLNheegj1icdDXt6+Wg5I4DRB+GDSATdNmFLhNTQyIiPe3xlZ Ak3v0gn9O9VHGuBdgU8o4Ilu1xGSRrlgOYHP3bqucRv+Xghj7VojOsbnpQMzGAk4MiYm eSIw== MIME-Version: 1.0 X-Received: by 10.50.2.3 with SMTP id 3mr9333360igq.34.1433703205059; Sun, 07 Jun 2015 11:53:25 -0700 (PDT) In-Reply-To: <55749025.8090501@cdreimer.com> References: <55747C96.7090006@cdreimer.com> <55749025.8090501@cdreimer.com> Date: Mon, 8 Jun 2015 04:53:24 +1000 Subject: Re: Python Random vs. Cython C Rand for Dice Rolls From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433703214 news.xs4all.nl 2857 [2001:888:2000:d::a6]:50950 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92290 On Mon, Jun 8, 2015 at 4:40 AM, C.D. Reimer wrote: > PS Z:\projects\programming\python\basic_games\fastdice> python > test_fastdice.py > > TOTAL SPOTS NUMBER OF TIMES > > 2 1389911 > > 3 2777722 > > 4 4168248 > > 5 5553632 > > 6 6944907 > > 7 8334670 > > 8 6945597 > > 9 5553557 > > 10 4167485 > > 11 2775806 > > 12 1388465 > > 1.65599989891 > > > I had to put the array definition outside of the function declaration, where > it's automatically initialized to zero in the global space. Yep, that's one valid way to force them all to zero (per C spec). And now you're seeing reasonable values. The rand() function may not be all that great, but it certainly isn't responsible for the bizarre values you were seeing :) ChrisA