On Thu, Apr 28, 2011 at 2:54 AM, Nick Coghlan <ncogh...@gmail.com> wrote: .. > No, as Raymond has articulated a number of times over the years, it's > a property of the equivalence relation that is needed in order to > present sane invariants to users of the container. I included in the > bug report the critical invariants I am currently aware of that should > hold, even when the container may hold types with a non-reflexive > definition of equality: > > assert [x] == [x] # Generalised to all container types > assert not [x] != [x] # Generalised to all container types > for x in c: > assert x in c > assert c.count(x) > 0 # If applicable > assert 0 <= c.index(x) < len(c) # If applicable >
It is an interesting question of what "sane invariants" are. Why you consider the invariants that you listed essential while say if c1 == c2: assert all(x == y for x,y in zip(c1, c2)) optional? Can you give examples of algorithms that would break if one of your invariants is violated, but would still work if the data contains NaNs? _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com