forked from modular/mojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mojo-stdlib] Dict iteration over keys, value, entries (#30936)
- `Dict.__iter__` iterates over dict keys, immutably - `Dict.keys()` iterates over dict keys, immutably - Note that this is different from Python. `Dict.keys()` in Python is a `key view` collection, which is immutable and implements the semantics of a set. What we're doing here isn't incompatible with that long-term. - `Dict.items()` iterates over dict entries, immutably - If there's a way to just allow mutability on `value` I don't see it - Unlike Python these can't be unpacked to `k, v`. We could implement that with [Internal Link] - `Dict.values()` iterates over dict values, **maybe mutably**. - This is okay because mutating the values can't impact the integrity of the dictionary internals. Stack: - [Internal Link] - [Internal Link] - [Internal Link] - -> [Internal Link] modular-orig-commit: 7c9ee251a9b407492f61facf9f3f79c750d19790
- Loading branch information
1 parent
e6356e0
commit be84840
Showing
2 changed files
with
284 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters