Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-39425: Document list.count() corner case #18130
Conversation
This comment has been minimized.
This comment has been minimized.
|
cc @corona10 |
This comment has been minimized.
This comment has been minimized.
|
FYI CPython 3.7.2, CPython master branch, PyPy 7.1.1 and PyPy3 7.1.1-beta0 all give the same result:
|
| @@ -994,6 +994,11 @@ Notes: | |||
| without copying any data and with the returned index being relative to | |||
| the start of the sequence rather than the start of the slice. | |||
|
|
|||
| (9) | |||
| In CPython, :meth:`tuple.count` and :meth:`list.count` consider that an | |||
This comment has been minimized.
This comment has been minimized.
ammaraskar
Jan 22, 2020
Member
I would suggest rephrasing to:
In CPython,
tuple.countandlist.countconsider an element to be equal to x if it is identical to x (ifelement is xis true) skipping the call to element's__eq__()method.
or maybe even
skipping the result of
element == x
for the last part.
This comment has been minimized.
This comment has been minimized.
|
I don't think this is a good idea, at least not on its own. The behavior is all over the place. For example, off the top of my head, in |
This comment has been minimized.
This comment has been minimized.
Can we document it somewhere else in this case? |
This comment has been minimized.
This comment has been minimized.
For all I know, it already is Because |
vstinner commentedJan 22, 2020
•
edited by bedevere-bot
https://bugs.python.org/issue39425