Skip to content

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

Closed

Description

@sobolevn

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

Activity

  1. changed the title [-]`dict_keys` is missing several methods[/-] [+]`dict_keys`, `dict_values`, and `dict_items` are missing several methods[/+] on Aug 16, 2021
  2. DimitrisJim commented on Aug 16, 2021

    @DimitrisJim
    Member

    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.

  3. DimitrisJim commented on Aug 16, 2021

    @DimitrisJim
    Member

    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.

  4. youknowone commented on Nov 28, 2021

    @youknowone
    Member

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

  5. rvsampson94 commented on Nov 30, 2021

    @rvsampson94
    Contributor

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

  6. John15321 commented on May 27, 2022

    @John15321

    Hey if its done you guys should close the issue :)

  7. youknowone commented on May 27, 2022

    @youknowone
    Member

    @John15321 thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions