On Mar 23, 2020, at 19:52, Steven D'Aprano steve@pearwood.info wrote:

On Mon, Mar 23, 2020 at 06:03:06PM -0700, Andrew Barnert wrote: The existing methods are named issubset and issuperset (and isdisjoint, which doesn’t have an operator near-equivalent). Given that, would you still want equals instead of isequal or something?

Oops! I mean, aha, you passed my test to see if you were paying attention, well done!

*wink*

I would be satisfied by "isequal", if the method were needed.

So, I’d rather have an uglier, more explicit, and more obviously specific-to-set name like iscoextensive. Sure, not everyone will know what “coextensive” means

That's an unnecessary use of jargon

As far as I’m aware (and your MathWorld search bears this out), “coextensive” isn’t mathematical jargon. I chose it because of its ordinary (if not super-common) English meaning. For example, the charter of the City of San Francisco says that the city is coextensive with the County of San Francisco, meaning that any bit of land in the city is in the county and vice-versa. I’m sure it’s not the only word that’s close enough to be pressed into service (historical Christian theology has to be full of words for similar ideas, right?); as I said; it’s just the first one that came to mind. Maybe something longer like has_same_elements would be better. But I would be a little surprised if any really common single word got the idea across.

that doesn't add clarity or precision and can only add confusion. Outside of the tiny niche of people trying to prove the foundations of mathematics in first-order logic and set theory, when mathematicians want to say two sets are equal, they say they are equal, they don't use the term “coextensive”.

Sure, but in math, just as in Python, a set is never equal to a list (with a tiny foundations asterisk that isn’t relevant, but I’ll mention it below).

So when mathematicians want to say a set is equal to a list… well, they just don’t say that, because it isn’t true, and usually isn’t even a meaningful question in the first place.

See, for example, Mathworld, which uses "=" in the usual way:

And in Python, it’s spelled “==“ instead of “=“, but otherwise, it already works the same way.

and doesn't even have a definition for “coextensive”:

https://mathworld.wolfram.com/search/?query=coextensive&x=0&y=0

Sure. In fact, I suspect there’s no standard symbol or name for this operation. Just like there’s no standard name for “divisible by 3 but not by 2”, there’s no standard name for “not necessarily equal, but the sets of their respective elements are equal”. Those descriptions are way too long for method names even in Objective C, much less Python, but that doesn’t mean you can call a method for the former “isodd”, or the latter “isequal”, because those names more strongly imply a much more commonly useful operation than they do the one you’re intending.

Of course (both in math and in Python) probably you just write the 1-liner in-line, or maybe give it a “local” name and expect people to refer to the definition only 10 lines above. We only really need a good, meaningful, non-confusing name for this operation if it’s really important enough to add as a builtin method.

The foundations of mathematics is one of those things which are extremely over-represented on the Internet

Well, you’re the only one who brought up foundations here, and in the same email where you’re railing against people talking about foundations on the internet, so I’m not sure what the point is.

My guess is that you saw Greg, Marc-Andre, etc. talking about sets in mathematics and naturally thought “oh no, here comes irrelevant mathematical logic”, but there isn’t any; the reason sets came up is that we’re talking about set operations on Python set objects, and it’s pretty hard to talk about what issubset means/should mean without talking about sets. (And the message you’re replying to here doesn’t even do that; it’s just about the practical issues of equals methods in programming languages.)

But I’ll give it something to be retroactively sequitur to, that tiny asterisk mentioned above: When you’re dealing with foundations, you do often define everything, including lists, as sets, so picking one common set of definitions arbitrarily, {1,{1,{2,{2,3}}}} = [1,2,3] is actually true. But that isn’t relevant, and wouldn’t be relevant even if all mathematicians were always worried about foundations and always used those particular definitions, because that obviously isn’t the operation the other Steve is looking for.