This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2019年07月13日 11:58 by Kristian Klette, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 14737 | closed | python-dev, 2019年07月13日 12:04 | |
| PR 14954 | merged | aeros, 2019年07月26日 05:28 | |
| PR 15908 | merged | miss-islington, 2019年09月11日 10:01 | |
| PR 15909 | merged | miss-islington, 2019年09月11日 10:01 | |
| Messages (8) | |||
|---|---|---|---|
| msg347806 - (view) | Author: Kristian Klette (Kristian Klette) * | Date: 2019年07月13日 11:58 | |
As a user, I expect to be able to compare the different parts a `dict`
in the same manner.
Currently, `PyDictValues` does not implement the `dictview_richcompare`, causing the `__eq__` to always return false, even if the values are identical.
```
my_dict = {'foo': 'bar'}
dict_copy = my_dict.copy()
other_dict = {'foo': 'bar', 'bar': 1234}
assert my_dict.keys() == my_dict.keys()
assert my_dict.keys() == dict_copy.keys()
assert my_dict.keys() != other_dict.keys()
assert my_dict.items() == my_dict.items()
assert my_dict.items() == dict_copy.items()
assert my_dict.items() != other_dict.items()
assert my_dict.values() == my_dict.values()
assert my_dict.values() == dict_copy.values()
assert my_dict.values() != other_dict.values()
```
|
|||
| msg347807 - (view) | Author: Karthikeyan Singaravelan (xtreak) * (Python committer) | Date: 2019年07月13日 12:36 | |
See also issue12445 which was a similar proposal rejected in the past. |
|||
| msg348462 - (view) | Author: Kyle Stanley (aeros) * (Python committer) | Date: 2019年07月26日 05:31 | |
Based on the current status of the discussion in python-dev, the most agreed upon solution so far seems to be updating the documentation to mention this behavior, rather than modifying the existing behavior. I opened a PR which updates the documentation for dict.values() to mention this, feel free to leave any suggestions. python-dev discussion archive: https://mail.python.org/archives/list/python-dev@python.org/thread/R2MPDTTMJXAF54SICFSAWPPCCEWAJ7WF/#723CHZBH4ZBKQJOOPXFFX3HYSPDBPDPR |
|||
| msg348463 - (view) | Author: Kyle Stanley (aeros) * (Python committer) | Date: 2019年07月26日 05:35 | |
Added Brett to the nosy list since he was the one who suggested a documentation change. |
|||
| msg350266 - (view) | Author: Kyle Stanley (aeros) * (Python committer) | Date: 2019年08月23日 08:23 | |
Reopening the issue for adding the documentation clarification, that comparing the values view of two dictionaries will always return false (as was suggested in the ML discussion https://mail.python.org/archives/list/python-dev@python.org/message/K3SYX4DER3WAOWGQ4SPKCKXSXLXTIVAQ/). A month ago, I opened to PR to add the clarification to the documentation for dict.values(): https://github.com/python/cpython/pull/14954/files. It probably went unnoticed because the issue had already been closed (which I hadn't realized at the time). |
|||
| msg351791 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2019年09月11日 10:01 | |
New changeset 6472ece5a0fe82809d3aa0ffb281796fcd252d76 by Brett Cannon (Kyle Stanley) in branch 'master': bpo-37585: Add clarification regarding comparing dict.values() (GH-14954) https://github.com/python/cpython/commit/6472ece5a0fe82809d3aa0ffb281796fcd252d76 |
|||
| msg351808 - (view) | Author: miss-islington (miss-islington) | Date: 2019年09月11日 10:45 | |
New changeset 3cd147bf599f116593dc06ed7dfe948b759aabd3 by Miss Islington (bot) in branch '3.7': bpo-37585: Add clarification regarding comparing dict.values() (GH-14954) https://github.com/python/cpython/commit/3cd147bf599f116593dc06ed7dfe948b759aabd3 |
|||
| msg351809 - (view) | Author: miss-islington (miss-islington) | Date: 2019年09月11日 10:46 | |
New changeset 690a16d455603500a0c6df0bd87e49c9b37a6950 by Miss Islington (bot) in branch '3.8': bpo-37585: Add clarification regarding comparing dict.values() (GH-14954) https://github.com/python/cpython/commit/690a16d455603500a0c6df0bd87e49c9b37a6950 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:18 | admin | set | github: 81766 |
| 2019年09月11日 10:46:55 | miss-islington | set | messages: + msg351809 |
| 2019年09月11日 10:45:57 | miss-islington | set | nosy:
+ miss-islington messages: + msg351808 |
| 2019年09月11日 10:03:37 | brett.cannon | set | status: open -> closed stage: patch review -> resolved |
| 2019年09月11日 10:01:59 | miss-islington | set | pull_requests: + pull_request15550 |
| 2019年09月11日 10:01:53 | miss-islington | set | pull_requests: + pull_request15549 |
| 2019年09月11日 10:01:45 | brett.cannon | set | messages: + msg351791 |
| 2019年08月23日 21:35:38 | aeros | set | stage: resolved -> patch review |
| 2019年08月23日 08:23:10 | aeros | set | status: closed -> open messages: + msg350266 |
| 2019年07月26日 05:35:02 | aeros | set | nosy:
+ brett.cannon messages: + msg348463 |
| 2019年07月26日 05:31:33 | aeros | set | nosy:
+ aeros messages: + msg348462 |
| 2019年07月26日 05:28:32 | aeros | set | pull_requests: + pull_request14723 |
| 2019年07月13日 12:49:40 | serhiy.storchaka | set | status: open -> closed resolution: duplicate superseder: dict view values objects are missing tp_richcmp and tp_as_number stage: patch review -> resolved |
| 2019年07月13日 12:36:58 | xtreak | set | nosy:
+ xtreak, methane messages: + msg347807 |
| 2019年07月13日 12:04:11 | python-dev | set | keywords:
+ patch stage: patch review pull_requests: + pull_request14531 |
| 2019年07月13日 11:58:48 | Kristian Klette | create | |