New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

Currently collections.Counter implements both __eq__ and __ne__ methods. The 
problem is that if you subclass Counter and override its __eq__ method you will 
need to implement also the __ne__ method. Usually you do not need to implement 
__ne__ because the implementation inherited from the object class does the 
right thing in most cases (unless you implement NumPy or symbolic expressions). 
Also, the Python implementation of Counter.__ne__ is a tiny bit slower than the 
C implementation of object.__ne__.

Counter.__ne__ was added because the implementation of __ne__ inherited from 
dict did not work correct for Counter. But we can just restore the default 
implementation:

    __ne__ = object.__ne__

Of all Python classes in the stdlib which implement __eq__ only Counter, 
WeakRef and some mock classes implement also __ne__. In case of Counter I think 
it is not necessary.

----------
components: Library (Lib)
messages: 374306
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Restore default implementation of __ne__ in Counter
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41397>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to