mozillazg / pypy

The unofficial GitHub mirror of PyPy (mirrored via https://github.com/mozillazg/job-mirror-hg-repos)
https://foss.heptapod.net/pypy/pypy
Other
443 stars 64 forks source link

Potential Bug in collections.Counter #15

Closed Al7ech closed 1 year ago

Al7ech commented 1 year ago

Abstract: pypy returns False for

Counter(a=4, b=2, c=0) == Counter(a=4, b=2)

Hi, while writing a simple code, I found a potential bug from Counter class. As written in abstract, pypy returns False for Counter(a=4, b=2, c=0) == Counter(a=4, b=2), while Python3 returns True for the same.

The reason seems to be the absence of __eq method in pypy's Counter class, while cpython's Counter class [has](https://github.com/python/cpython/blob/a6675b1a597c67be972598ac8562883fabe48099/Lib/collections/init__.py#L784).

Considering the characteristics of the Counter class, returning True to the upper statement seems to be more reasonable. Maybe pypy should add __eq__ statement too.

Al7ech commented 1 year ago

Well, lately I found out that this repo is mirror. I'll close this issue.