[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2022-01-29 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +29195
pull_request: https://github.com/python/cpython/pull/21628

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2020-07-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

If you want to add back the __ne__() method, that would be fine.

FWIW, "class A(collections.abc.Set, int)" seems pretty exotic to me.  I 
wouldn't have expected that work out well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2020-07-28 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
Removed message: https://bugs.python.org/msg374497

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2020-07-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> if we have a class which inherits from both Set and int

This really seems like an invented problem rather than an actual problem.

> class A(collections.abc.Set, int): pass

Would anyone ever do this and be surprised the sets and ints don't combine 
perfectly?

If you must, add a footnote to the collections.abc entry for __ne__ noting that 
__ne__ is inherited.  Or you can restore the definition of Set.__ne__ that was 
present in 3.4.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2020-07-28 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

According to the documentation [1] abstract classes collections.abc.Set and 
collections.abc.Mapping provide mixin method __ne__. But implementations of 
__ne__ in these classes were removed in 3.4 (see issue21408), so the default 
implementation is inherited from object. The reason is that it works better 
with classes which override __ne__ to return non-boolean, e.g. NumPy, SymPy and 
sqlalchemy classes. Previously the != operator falled back to other__eq__(), 
now it falls back to other__ne__().

[1] 
https://docs.python.org/3/library/collections.abc.html#collections-abstract-base-classes

But now we have a discrepancy between the decomentation and the code. According 
to the documentation, if we have a class which inherits from both Set and int, 
in that order, the __ne__ method should be inherited from class Set instead of 
class int. But currently it is inherited from int.

>>> import collections.abc
>>> class A(collections.abc.Set, int): pass
... 
>>> A.__ne__


One way to solve this -- remove __ne__ from lists of mixin methods (see 
issue41400). Other way -- add the __ne__ implementations which are identical to 
the default implementation but has preference in the inheritance. I prefer the 
latter.

--
components: Library (Lib)
messages: 374470
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Restore default implementation of __ne__ in mixins Set and Mapping
type: behavior
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2020-07-28 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +20795
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21628

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41416] Restore default implementation of __ne__ in mixins Set and Mapping

2020-07-28 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests:  -20795

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com