Tim Peters <[EMAIL PROTECTED]> added the comment:

Vadim, to see how memory addresses change, simply add something like

    print "id", id(self)

to Sequence.__init__.  On Windows (Vista, Python 2.5.1), I see different
addresses printed each time the program is run.  Then, as Martin said,
the default implementation of __hash__ for a type uses the object's
memory address, and that's both unpredictable across runs and influenced
within a run by just about everything the script does (indeed, adding
the `print` statement above may well change the addresses of Sequence
objects created after the print executes!).

What is deterministic:  within a single program run, if you iterate over
a given set multiple times, the set elements will be delivered in the
same order each time, provided you don't mutate the set for the duration.

More than that isn't guaranteed.  For example, if you have two sets x
and y, it's not even the case that x == y implies list(x) == list(y). 
For example,

>>> x = set(range(-10, 11))
>>> y = set(reversed(range(-10, 11)))
>>> x == y
True
>>> list(x) == list(y)
False

If I were you, I'd change the script to use lists instead of sets here
until the algorithm is debugged.  Then you'll get wholly deterministic
behavior, which will make debugging easier.  You can make it run faster
later ;-)

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3497>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to