Hmm, I see ints, floats and decimal.Decimal all produce the same hashes
for integer values, so they also suffer the same fate in sets and
dicts.

On Mon, 2020-12-21 at 03:09 -0500, David Mertz wrote:
> I sure hope this never happens! It would break millions of working
> lines and kill a common useful pattern.
> 
> ntrue = sum(this == that for this, that in items)
> 
> -100.
> 
> On Mon, Dec 21, 2020, 3:00 AM Paul Bryan <pbr...@anode.ca> wrote:
> > I know this has come up in the past.
> > 
> > Could the consensus have changed regarding bool's inheritance from
> > int?
> > 
> > This is not intuitive (to me), and recently bit me as a bug:
> > 
> > Python 3.9.1 (default, Dec 13 2020, 11:55:53) 
> > [GCC 10.2.0] on linux
> > Type "help", "copyright", "credits" or "license" for more
> > information.
> > >>> {1,True}
> > {1}
> > 
> > 
> > I've worked around it by storing tuple(type, value) in the set,
> > which is fugly. Yes, I need mixed types in the set, and I'm using
> > the set for efficient lookup.
> > 
> > A contrived example I dreamed-up, which I also find non-intuitive:
> > 
> > >>> x = {}
> > >>> x[True] = 1
> > >>> x
> > {True: 1}
> > >>> x[1] = 1
> > >>> x
> > {True: 1}
> > 
> > 
> > Maybe a wish list item for Python 4.0?
> > 
> > _______________________________________________
> > Python-ideas mailing list -- python-ideas@python.org
> > To unsubscribe send an email to python-ideas-le...@python.org
> > https://mail.python.org/mailman3/lists/python-ideas.python.org/
> > Message archived at
> >
> https://mail.python.org/archives/list/python-ideas@python.org/message/3GIWJ3IOTZMJ3ZFPJPQ3EF3SSLBEOSID/
> > Code of Conduct: http://python.org/psf/codeofconduct/
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/73N4MHFPIINAH6R2SI64KHISH53CEIQF/
> Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/R4VT76SDOTIESYOZACKJL54ED56EJMZ4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to