| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -4181,6 +4181,12 @@ another set. The :class:`frozenset` type is immutable and :term:`hashable` --- | |||||||||
| its contents cannot be altered after it is created; it can therefore be used as | ||||||||||
| a dictionary key or as an element of another set. | ||||||||||
|
|
||||||||||
| Note that as long as the objects have the same hash values, they are seen as | ||||||||||
| equivalent by sets:: | ||||||||||
|
|
||||||||||
| >>> {0, True, False, 1} | ||||||||||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCould you please add some of the types Terry listed in the issue too? I was frankly surprised at them (especially the Decimal and Fractions with the same hash value).
Suggested change
Sorry, something went wrong.
AlexWaygood and kumaraditya303 reacted with thumbs up emoji
All reactions
|
||||||||||
| {0, True} | ||||||||||
|
|
||||||||||
| Non-empty sets (not frozensets) can be created by placing a comma-separated list | ||||||||||
| of elements within braces, for example: ``{'jack', 'sjoerd'}``, in addition to the | ||||||||||
| :class:`set` constructor. | ||||||||||
| Expand Down Expand Up | @@ -4383,6 +4389,20 @@ then they can be used interchangeably to index the same dictionary entry. (Note | |||||||||
| however, that since computers store floating-point numbers as approximations it | ||||||||||
| is usually unwise to use them as dictionary keys.) | ||||||||||
|
|
||||||||||
| This also means if two keys have the same hash values, they will map to the same | ||||||||||
| entry in the dictionary:: | ||||||||||
|
Comment thread
Comment on lines
+4392
to
+4393
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySame as above.
Sorry, something went wrong.
All reactions
|
||||||||||
|
|
||||||||||
| >>> {0: 0, False: 0} | ||||||||||
| {0: 0} | ||||||||||
|
|
||||||||||
| However, note that when a key with the same hash as an existing key is inserted | ||||||||||
| into a dictionary, it replaces the value but not the key:: | ||||||||||
|
|
||||||||||
| >>> d = {False: 'false'} | ||||||||||
| >>> d[0] = 0 | ||||||||||
| >>> d | ||||||||||
| {False: 0} | ||||||||||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Sorry, something went wrong.
All reactions
|
||||||||||
|
|
||||||||||
| .. class:: dict(**kwargs) | ||||||||||
| dict(mapping, **kwargs) | ||||||||||
| dict(iterable, **kwargs) | ||||||||||
| Expand Down | ||||||||||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt is not true.
>>> hash(1) == hash(2**61) True >>> {1, 2**61} {1, 2305843009213693952}Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.