Different Random Numbers Between Already/Not Yet Compiled Code

Eric Eide eeide at cs.utah.edu
Thu Jan 24 15:29:31 EST 2002


Short story: `random' turned out not to be the trouble at all.

After some investigation, I discovered the reason for the difference between
the output of my compiled and non-compiled Python program: it was due to
getting different arrangements of tuples from the dictonary `items' method.

When my simulation program iterated over the list returned by `items', it
applied a predictable series of random numbers to an unpredictable arrangement
of my objects, thus yielding unpredictable results.

Sorting the returned `items' list before iterating over it solved my
unpredictability problem, and now my program yields consistent results whether
the Python source files are precompiled or not.

Thanks for all the good advice in tracking down this problem!

Eric.

-- 
-------------------------------------------------------------------------------
Eric Eide <eeide at cs.utah.edu>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX



More information about the Python-list mailing list