On Thu, 28 Feb 2019 22:43:04 +1100 Steven D'Aprano firstname.lastname@example.org wrote:
On Wed, Feb 27, 2019 at 02:15:53PM -0800, Barry Warsaw wrote:
I’m just relaying a data point. Some Python folks I’ve worked with do make the connection between dicts and sets, and have questions about the ordering guarantees of then (and how they relate).
Sets and dicts are not related by inheritence (except that they're both subclasses of ``object``, but so is everything else). They don't share an implementation. They don't provide the same API. They don't do the same thing, except in the most general sense that they are both collections.
What connection are these folks making?
Some of them may be coming from C++, where the respective characteristics of set and map (or unordered_set and unordered_multimap) are closely related. I'm sure other languages show similar analogies.
On a more abstract level, set and dict are both content-addressed collections parametered on hash and equality functions. For algorithmically-minded people it makes sense to see a close connection between them.