At 10:26 AM 9/29/2007 -0500, Michael Urman wrote: > This isn't just a matter of dicts; any collection type can be susceptible.
The reason that dicts (and sets) are even worse is that the comparison could be delayed. If b"bytes" in [...] raises an exception, it happens while b"bytes" is still in the traceback context. With a dictionary, the problem comparison could be delayed until the next resize. Even if the TypeError did tell you which dict and (pair of pre-existing) keys were a problem, you still wouldn't know how those keys got there. Example data flow: insert string1 with hash X insert string2 with hash X -- collision, so it moves to the next slot del string1 insert bytes with hash X -- replaces the dummy entry, so nothing raised yet ... insert something utterly unrelated, such as an integer. This causes a resize, so that now string2 and bytes do collide and raise a TypeError complaining about strings and bytes -- even though the key you added is neither. -jJ _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com