←back to thread

191 points jwilk | 1 comments | | HN request time: 0.221s | source
Show context
drhagen ◴[] No.46230206[source]
Great! Now make `set` have a stable order and we're done here.
replies(1): >>46230375 #
cr125rider ◴[] No.46230375[source]
Aren’t sets unsorted by definition? Or do repeated accesses without modification yield different results?
replies(4): >>46230852 #>>46230876 #>>46230887 #>>46231151 #
ledauphin ◴[] No.46230876[source]
this is likely in reference to the fact that dicts have maintained insertion order since Python ~3.6 as property of the language. Mathematically there's no defined order to a set, and a dict is really just a set in disguise, but it's very convenient for determinism to "add" this invariant to the language.
replies(2): >>46230993 #>>46231182 #
1. zahlman ◴[] No.46231182[source]
Sets use a different implementation intentionally (i.e. they are not "a dict without values") exactly because it's expected that they have different use cases (e.g. union/intersection operations).