Different Random Numbers Between Already/Not Yet Compiled Code

Eric Eide eeide at cs.utah.edu
Mon Jan 21 20:11:19 EST 2002


[This is a vague, hand-wavy bug report.  Mostly I'm interested in finding out
if the behavior I'm seeing is worth further investigation, by me or by a Python
wizard.]

I have a small Python program that uses the `random' module to drive a little
simulation.  My code uses the default generator instance; i.e., I just call the
functions without making my own generator object.  At the start of my program
(when I create an instance of my overall `Model' class), I call `random.seed'
to initialize the random number generator.  So far, so good.

Unfortunately, even with explicit seeding, I've found that I don't always get
reproducible results.  In particular, I've found that if I delete one of my
`.pyc' files, then the output of the next program run is different!  The
divergence happens a little ways into the run of the program --- not quite at
the start, but soon after.  The run after that --- which starts with the `.pyc'
file in place --- is back to normal.

Does anybody have any idea what might be going on?  I haven't yet tried making
my own `whrandom' object, although that's an obvious avenue for isolating my
code from whatever might be going on.  Basically, I'm just surprised that I
would see the difference that I'm seeing.  Any ideas?

Thanks ---

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