RE: Testing slightly different python randomisation maneuvers

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 5 May 2011 13:38:48 -0400

Hi Jacob,
I'm sorry. I don't get this. Can you please explain in smaller steps?

Thanks.

Jim

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jacob Kruger
Sent: Thursday, May 05, 2011 12:49 PM
To: programmingblind@xxxxxxxxxxxxx
Cc: program-l@xxxxxxxxxxxxx
Subject: Re: Testing slightly different python randomisation manoeuvres

Oh yes, and it literally comes down to either using the simpler version:
random.randint(1, 100)

Or the more manual version:
int(random.random() * 100)

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message -----
From: "Jacob Kruger" <jacobk@xxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Cc: <program-l@xxxxxxxxxxxxx>
Sent: Thursday, May 05, 2011 4:19 PM
Subject: Testing slightly different python randomisation manoeuvres


Testing python randomising a number between 1 and 100, repeating process 100
thousand times, the automatic integer output method took approximately 279
milliseconds the slightly more involved (in terms of having to convert
randomised number into a clean integer in the right range) method took
approximately 59 milliseconds - the difference was 220 milliseconds slower
if you asked it to automatically give you a number in the range 1 to 100, as
opposed to taking the decimal/floating point number more automatically
generated, and multiplying it then by 100, and converting it to an integer
as such.

This is something that almost immediately popped up in my mind when was
reviewing the various randomisation objects/methods provided by modules
built into python, after had already made my own workaround for spitting out
a clean integer between 1 and 100, and then thought of double checking if
there was some or other built in/automatic process to generate one as such,
and then I put together the little bit of code to test the differences in
execution time...<smile>

Dunno why I thought of trying this out, since am actually just busy going
through one of the learn python books, and while working through pieces on
lists and dictionary objects, I was messing around with storing the full
alphabet in these collection objects, and then spitting out a random letter,
etc. etc., and it just ended up making me get around to thinking
about/considering this.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed.  If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it.  If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
 The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: