change of random state when pyc created??

Robert Kern robert.kern at gmail.com
Wed May 9 22:18:25 EDT 2007


Alan Isaac wrote:
>>> Robert Kern wrote:
>>>> http://docs.python.org/lib/typesmapping.html
>>>> """
>>>> Keys and values are listed in an arbitrary order which is non-random,
> varies
>>>> across Python implementations, and depends on the dictionary's history
> of
>>>> insertions and deletions.
>>>> """
> 
>> Alan G Isaac wrote:
>>> Even this does not tell me that if I use a specified implementation
>>> that my results can vary from run to run.  That is, it still does
>>> not communicate that rerunning an *unchanged* program with an
>>> *unchanged* implementation can produce a change in results.
> 
> "Robert Kern" <robert.kern at gmail.com> wrote in message
> news:mailman.7488.1178744519.32031.python-list at python.org...
>> The last clause does tell me that.
> 
> 1. About your reading of the current language:
> I believe you, of course, but can you tell me **how** it tells you that?
> To be concrete, let us suppose parallel language were added to
> the description of sets.  What about that language should allow
> me to anticipate Peter's example (in this thread)?

Actually, the root cause of Peter's specific example is the fact that the
default implementation of __hash__() and __eq__() rely on identity comparisons.
Two separate invocations of the same script give different objects by identity
and thus the "history of insertions and deletions" is different.

> 2. About possibly changing the docs:
> You are much more sophisticated than ordinary users.
> Did this thread not demonstrate that even sophisticated users
> do not see into this "implication" immediately? 

Well, if you had a small test case that demonstrated the problem, we would have.
Your example was large, complicated, and involved other semi-deterministic red
herrings (the PRNG). It's quite easy to see the problem with Peter's example.

> Replicability
> of results is a huge deal in some circles.  I think the docs
> for sets and dicts should include a red flag: do not use
> these as iterators if you want replicable results.
> (Side note to Carsten: this does not require listing "every little thing".)

They do. They say very explicitly that they are not ordered and that the
sequence of iteration should not be relied upon. The red flags are there.

But I'm not going to stop you from writing up something that's even more explicit.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list