Skip to content
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

dict_keys, dict_values, and dict_items are missing several methods #2898

Open
sobolevn opened this issue Aug 16, 2021 · 4 comments
Open

dict_keys, dict_values, and dict_items are missing several methods #2898

sobolevn opened this issue Aug 16, 2021 · 4 comments

Comments

@sobolevn
Copy link
Contributor

@sobolevn sobolevn commented Aug 16, 2021

Feature

CPython:

>>> dir(dict().keys())
['__and__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__rand__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__ror__', '__rsub__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__xor__', 'isdisjoint']

RustPython:

>>>>> dir(dict().keys())
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__str__', '__subclasshook__']

Diff:

  • '__contains__'
  • '__and__'
  • '__rxor__'
  • 'isdisjoint'
  • '__or__'
  • '__rand__'
  • '__ror__'
  • '__xor__'
  • '__rsub__'
  • '__sub__'
  • '__sizeof__'

The same is for dict_values and dict_items

@sobolevn sobolevn changed the title dict_keys is missing several methods dict_keys, dict_values, and dict_items are missing several methods Aug 16, 2021
@DimitrisJim
Copy link
Member

@DimitrisJim DimitrisJim commented Aug 16, 2021

Yup, I don't think a macro should be used to generate the types as is currently done. For their respective iterators, the macro seems like a good idea, for the types, not that much.

@DimitrisJim
Copy link
Member

@DimitrisJim DimitrisJim commented Aug 16, 2021

Additionally, though item in view currently works (falling back to iterating), it can be O(1) for keys and items views by keying the dict ref they hold.

@youknowone
Copy link
Member

@youknowone youknowone commented Nov 28, 2021

is this done? can we list up what's done and left?

@rvsampson94
Copy link
Contributor

@rvsampson94 rvsampson94 commented Nov 30, 2021

I think sizeof is the last one that needs to be merged. After that it should be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants