-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
gh-141510: Update Whats News for frozendict #144961
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,14 +188,30 @@ raise :exc:`SyntaxError`). | |
| :pep:`814`: Add frozendict built-in type | ||
| ---------------------------------------- | ||
|
|
||
| A new public immutable type :class:`frozendict` is added to the :mod:`builtins` | ||
| module. It is not a ``dict`` subclass but inherits directly from ``object``. | ||
|
|
||
| A ``frozendict`` can be hashed with ``hash(frozendict)`` if all keys and values | ||
| can be hashed. | ||
| A new public immutable type, :class:`frozendict`, is added to the :mod:`builtins` module. | ||
| It does not allow modification after creation. A ``frozendict`` is not a subclass of ``dict``; | ||
| it inherits directly from ``object``. A ``frozendict`` is hashable (i.e., ``hash(frozendict)`` works) | ||
|
||
| as long as all of its keys and values are hashable. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, you may add that it preserves insertion order, but that comparison doesn't take the order in account (your example proves it). |
||
| >>> a = frozendict(x=1, y=2) | ||
| >>> a | ||
| frozendict({'x': 1, 'y': 2}) | ||
| >>> a['z'] = 3 | ||
| Traceback (most recent call last): | ||
| File "<python-input-2>", line 1, in <module> | ||
| a['z'] = 3 | ||
| ~^^^^^ | ||
| TypeError: 'frozendict' object does not support item assignment | ||
| >>> b = frozendict(y=2, x=1) | ||
| >>> hash(a) == hash(b) | ||
| True | ||
| >>> a == b | ||
| True | ||
corona10 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. seealso:: :pep:`814` for the full specification and rationale. | ||
|
|
||
| (Contributed by Victor Stinner and Donghee Na in :gh:`141510`.) | ||
|
|
||
|
|
||
| .. _whatsnew315-profiling-package: | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.