-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
bpo-39425: Document list.count() corner case #18130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cc @corona10 |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest rephrasing to:
In CPython,
tuple.count
andlist.count
consider an element to be equal to x if it is identical to x (ifelement is x
is true) skipping the call to element's__eq__()
method.
or maybe even
skipping the result of
element == x
for the last part.
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 |
Can we document it somewhere else in this case? |
For all I know, it already is 😉. Sorry, I'm not intimately familiar with the docs anymore. Because |
If it is, I would not say that it's not well documented :-) For example, it's not mentionnned in the Maybe this method documentation would be a better place to describe CPython quirks? |
I suggest taking this to python-dev. It's not at all clear to me that this is just a pile of CPython quirks. For example, whether a NaN can be used as a dict key is something that "should" be defined by the language. Or if consensus is that this is just a pile of CPython quirks, then they need to be documented as such. Note that |
I brought this up on python-dev: https://mail.python.org/archives/list/python-dev@python.org/thread/3ZAMS473HGHSI64XB3UV4XBICTG2DKVF/ and I endorse Guido's reply (very briefly, that it should be documented in a general way, but that it's implementation-defined). |
There is a consensus to not document it in list.count() documentation, so I close my PR. |
https://bugs.python.org/issue39425