3 ms·
Formatting of several of the code segments is borked. It should be mentioned that a Python set type is basically a naked hash table, or a dictionary with all k
by fernly 6y ago
Formatting of several of the code segments is borked.
It should be mentioned that a Python set type is basically a naked hash table, or a dictionary with all keys and no data.
As noted, in 3.6 dicts are ordered, but in 3.8 they can be reversed(); and in 3.9 the new merge and update operators are added:
https://docs.python.org/3.9/whatsnew/3.9.html#dictionary-merge-update-operators https://docs.python.org/3.9/whatsnew/3.9.html#dictionary-mer...
- pansa2 6y ago> a Python set type is basically a naked hash table, or a dictionary with all keys and no data. Not exactly. Dicts, as you say, are ordered - but sets are not.
- masklinn 6y ago> It should be mentioned that a Python set type is basically a naked hash table, or a dictionary with all keys and no data. Python's set and dict are actually completely different codebases. Notably, the naturally ordered hash table of 3.6 dicts is not used by or for sets.
- viraptor 6y agoIn case anyone is curious, sets were dicts in the original implementation: https://github.com/python/cpython/blob/a690a9967e715663b7a421c9ebdad91381cdf1e4/Objects/setobject.c https://github.com/python/cpython/blob/a690a9967e715663b7a42... It was changed in 2005 for python 2.5 https://github.com/python/cpython/commit/9f1a6796eb83a2884df5fd93487634e46d8830a7 https://github.com/python/cpython/commit/9f1a6796eb83a2884df...