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


Groups > comp.lang.python > #92290

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

References <55747C96.7090006@cdreimer.com> <CAPTjJmo0Aw961q54BySZBSDdD8xqCPFjMezcytzWxrE0m6afTw@mail.gmail.com> <55749025.8090501@cdreimer.com>
Date 2015-06-08 04:53 +1000
Subject Re: Python Random vs. Cython C Rand for Dice Rolls
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.272.1433703214.13271.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jun 8, 2015 at 4:40 AM, C.D. Reimer <chris@cdreimer.com> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python Random vs. Cython C Rand for Dice Rolls Chris Angelico <rosuav@gmail.com> - 2015-06-08 04:53 +1000

csiph-web