change of random state when pyc created??

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Wed May 9 22:55:38 EDT 2007


On Wed, 09 May 2007 21:18:25 -0500, Robert Kern wrote:

> 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.

The history is the same. The objects inserted are the same (by equality).
The memory address those objects are located at is different.

Would you expect that "hello world".find("w") should depend on the address
of the string "w"? No, of course not. Programming in a high level language
like Python, we hope to never need to think about memory addresses. And
that's the gotcha.



-- 
Steven.




More information about the Python-list mailing list