[BUG]: KeysView/ItemsView does not support set operations
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
master
Problem description
When calling .items()/.keys() on the result of bind_map<>() return a custom KeysView/ItemsView which don't implement set operations. Ref. Looking at the history there seems to be a lot of issues/pull requests around them. I assume there is some history about why they don't use collections.abc.KeysView/collections.abc.ItemsView type at runtime and have a custom implementation.
Reproducible example code
No set operations exist. See https://github.com/pybind/pybind11/pull/5877 for an example of 1.
Is this a regression? Put the last known working version here if it is.
Not a regression
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the bind_map<> result and the custom KeysView/ItemsView behavior described in the issue, then review the example in pull request #5877. Compare the available operations with Python's collections.abc KeysView and ItemsView expectations; done means the reported set operations work for these views without regressing existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100