3 ms·
Python remembers order, and exposes it in its iterations, but doesn't use it in its equivalence over dictionaries (== semantics). (ETA: What are you quoting th
by tonyg 2y ago
Python remembers order, and exposes it in its iterations, but doesn't use it in its equivalence over dictionaries (== semantics).
(ETA: What are you quoting there? I don't think that text appears on the Preserves site) (ETA2: Ah, it's the tutorial. Cool)
- sixdimensional 2y agoNot sure about the previous post, but also python’s OrderedDict collection guarantees order-sensitive equality checks. [1] Plain dict maintains insertion order but equality checks only check that the key/value pairs are the same. [2] [3] [1] https://docs.python.org/3/library/collections.html#:~:text=equality%20tests%20between%20ordereddict%20objects%20are%20order%2Dsensitive https://docs.python.org/3/library/collections.html#:~:text=e... [2] https://docs.python.org/3/library/stdtypes.html#:~:text=dictionaries%20preserve%20insertion%20order.%20 https://docs.python.org/3/library/stdtypes.html#:~:text=dict... [3] https://docs.python.org/3/library/stdtypes.html#:~:text=dictionaries%20compare%20equal%20if%20and%20only%20if%20they%20have%20the%20same%20(key%2C%20value)%20pairs%20(regardless%20of%20ordering).%20order%20comparisons%20(%E2%80%98%3C%E2%80%99%2C%20%E2%80%98%3C%3D%E2%80%99%2C%20%E2%80%98%3E%3D%E2%80%99%2C%20%E2%80%98%3E%E2%80%99)%20raise%20typeerror. https://docs.python.org/3/library/stdtypes.html#:~:text=dict...
- boxed 2y agoYea. Just pointing out that the order can be significant, so throwing it away isn't generally a good idea.