On Wed, Aug 1, 2018 at 7:43 PM, Robin Becker <ro...@reportlab.com> wrote: > On 01/08/2018 09:52, Chris Angelico wrote: >> >> On Wed, Aug 1, 2018 at 6:36 PM, Robin Becker <ro...@reportlab.com> wrote: >>> >>> On 31/07/2018 16:52, Chris Angelico wrote: >> >> .......... >>> >>> >>> it says explicitly that numeric keys will use numeric comparison, but no > > ......... >>> >>> >> >> Technically, the comparison used is: >> >> a is b or a == b >> >> in other words, identity will match, but mainly, equality is used. The >> identity check improves performance in many common cases, and also >> avoids pathological cases involving float("nan"), but in general >> discussion, it's assumed that value rather than identity is the >> comparison used. >> >> ChrisA >> > > If the testing were done in that order then no comparison warning would > occur as inspection shows 'a' is not b'a' > > > C:\code\hg-repos\reportlab\tmp>\python37\python.exe -b -Wall >> >> Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit >> (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> >>>>> 'a' is b'a' >> >> False >>>>> >>>>> > > so presumably the testing goes something like > > a is b or (a==b if comparable(a,b) else False) > > even so I still think errors/warnings created internally by implementers > should not be exposed. It's not a big deal. I'm a bit surprised that we > don't have a mapping which uses only identity as that would be faster. >
I'm not sure how you're interpreting the word 'or' in my explanation, but it has the same meaning it has in Python code. ChrisA -- https://mail.python.org/mailman/listinfo/python-list