On Tue, Jun 23, 2015 at 7:06 PM, Paul Rubin <no.email@nospam.invalid> wrote:
> Chris Angelico <ros...@gmail.com> writes:
>>> Would I have to do an O(n) search to find my key?
>> Iterate over it - it's an iterable view in Py3 - and compare.
>
> I think the question was whether the O(n) search could be avoided, not
> how to do it.  I don't see a way to avoid it.  There is fundamental
> brokenness in having unequal objects compare as equal, and the breakage
> messes up the dictionary when those objects are used as keys.

I don't think that it's fundamentally broken. A simple example would
be the int 3, vs. the float 3, vs. the Decimal 3. All of them compare
equal to one another, but they are distinct values, and sometimes it
might be useful to be able to determine which one is actually a key in
the dict.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to