[Python-Dev] == on object tests identity in 3.x - list delegation to members?
Andreas Maier
andreas.r.maier at gmx.de
Wed Jul 16 13:39:55 CEST 2014
Am 13.07.2014 18:23, schrieb Steven D'Aprano:
> On Sun, Jul 13, 2014 at 05:13:20PM +0200, Andreas Maier wrote:
>
>> Second, if not by delegation to equality of its elements, how would the
>> equality of sequences defined otherwise?
>
> Wow. I'm impressed by the amount of detailed effort you've put into
> investigating this. (Too much detail to absorb, I'm afraid.) But perhaps
> you might have just asked on the python-list at python.org mailing list, or
> here, where we would have told you the answer:
>
> list __eq__ first checks element identity before going on
> to check element equality.
I apologize for not asking. It seems I was looking at the trees
(behaviors of specific cases) without seeing the wood (identity goes first).
> If you can read C, you might like to check the list source code:
>
> http://hg.python.org/cpython/file/22e5a85ba840/Objects/listobject.c
I can read (and write) C fluently, but (1) I don't have a build
environment on my Windows system so I cannot debug it, and (2) I find it
hard to judge from just looking at the C code which C function is
invoked when the Python code enters the C code.
(Quoting Raymond H. from his blog: "Unless you know where to look,
searching the source for an answer can be a time consuming intellectual
investment.")
So thanks for clarifying this.
I guess I am arriving (slowly and still partly reluctantly, and I'm not
alone with that feeling, it seems ...) at the bottom line of all this,
which is that reflexivity is an important goal in Python, that
self-written non-reflexive classes are not intended nor well supported,
and that the non-reflexive NaN is considered an exception that cannot be
expected to be treated consistently non-reflexive.
> This was discussed to death some time ago, both on python-dev and
> python-ideas. If you're interested, you can start here:
>
> https://mail.python.org/pipermail/python-list/2012-October/633992.html
>
> which is in the middle of one of the threads, but at least it gets you
> to the right time period.
I read a number of posts in that thread by now. Sorry for not reading it
earlier, but the mailing list archive just does not lend itself to
searching the past. Of course, one can google it ;-)
Andy
More information about the Python-Dev
mailing list