Code with random module faster on the vm than the vm host...

Robert Kern robert.kern at gmail.com
Mon Nov 11 02:19:08 CET 2013


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




More information about the Python-list mailing list