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

alex23 wuwei23 at gmail.com
Sun Nov 10 19:49:37 EST 2013


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, which relies on OS implementations of 
randomness functionality:

"On a UNIX-like system this will query /dev/urandom, and on Windows it 
will use CryptGenRandom()."

http://docs.python.org/2/library/os.html#miscellaneous-functions

The linux implementation appears to be faster.



More information about the Python-list mailing list