Skip to content

Enhance Data Structures : Support for in iteration of dict #1881

Open

Description

@faze-geek
def f():
    d:dict[i32,i32] = {1 : 100,2 : 200,3 : 300,4 : 400}
    i:i32
    for i in d:      # for in works with string, list, tuple, set
        print(i) 
f()

(lp) C:\Users\kunni\lpython>python try.py
1
2
3
4

Activity

  1. changed the title [-]Enhance Data Structures: Support for iteration of `dict`[/-] [+]Enhance Data Structures : Support `for in` iteration of `dict`[/+] on Jun 7, 2023
  2. czgdp1807 commented on Jun 24, 2023

    @czgdp1807
    Collaborator

    First we have to implement dict.keys and dict.values (1 PR). And then we can implement for in for dict (and then a separate PR).

  3. kabra1110 commented on Jun 25, 2023

    @kabra1110
    Collaborator

    First we have to implement dict.keys and dict.values (1 PR)

    Should dict.keys be a list? CPython uses view objects, which do not support many list operations.

  4. czgdp1807 commented on Jun 25, 2023

    @czgdp1807
    Collaborator

    That’s true. For now let’s keep it as a list. Later if needed we can create a separate type for dict.keys.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions