Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'class,': 0.07; 'alias': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'runs': 0.10; 'python': 0.11; '2.7': 0.14; 'random': 0.14; 'windows': 0.15; 'kern': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:random': 0.16; 'underlying': 0.16; 'vmware': 0.16; 'win7': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'value.': 0.19; 'import': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'interpret': 0.24; 'subject:Code': 0.24; 'initial': 0.24; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'robert': 0.30; 'code': 0.31; 'pascal': 0.31; 'values.': 0.31; 'running': 0.33; 'subject:the': 0.34; 'subject:with': 0.35; 'no,': 0.35; 'but': 0.35; 'version': 0.36; 'method': 0.36; 'seconds': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'times': 0.62; 'our': 0.64; 'world': 0.66; 'believe': 0.68; 'default': 0.69; 'eco': 0.84; 'faster...': 0.84; 'seconds!': 0.84; 'terrible': 0.84; 'received:86': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: Code with random module faster on the vm than the vm host... Date: Mon, 11 Nov 2013 01:19:08 +0000 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: cpc2-cmbg17-2-0-cust347.5-4.cable.virginm.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384132761 news.xs4all.nl 15897 [2001:888:2000:d::a6]:54221 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59040 On 2013-11-11 00:49, alex23 wrote: > On 9/11/2013 3:48 AM, Pascal Bit wrote: >> from random import random > > [...] >> >> Running on win7 python 2.7 32 bit it uses around 30 seconds avg. >> Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds! >> The code runs faster on vm, than the computer itself... >> The python version in this case is 1.5 times faster... >> I don't understand. >> >> What causes this? > > The random module uses os.urandom, No, it doesn't. random.random() is an alias to the random() method on the random.Random class, which uses the Mersenne Twister to generate values. os.urandom() gets called in the initial default seeding, but not for each value. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco