[Tutor] Chutes & Ladders
Peter Otten
__peter__ at web.de
Mon Dec 23 10:09:16 CET 2013
Keith Winston wrote:
> On Sun, Dec 22, 2013 at 3:04 PM, <tutor-request at python.org> wrote:
>
>> To sum it up: I like what you have, my hints are all about very minor
>> points
>> :)
>>
>
>
> Peter, that's a bunch of great suggestions, I knew there were a lot of
> places to streamline, make more readable, and probably make faster. Thank
> you.
>
> I find that if I run it [10000] [10] times, it takes about 20s on my
> machine, so I'm eventually going to take a little time seeing how fast I
> can get it, I think... maybe I'll learn decorators so I can time it/parts
> of it?
>
> I'm really grateful for yours and everyone's help.
I don't expect any of my suggestions to have a significant impact on
execution speed. If you are looking for a cheap way to make your script a
bit faster try replacing
roll = random.randint(1,6)
with
roll = int(random.random() * 6) + 1
Further speedups may be gained from undoing (some of the) OO...
More information about the Tutor
mailing list