Christopher Barker writes:

 > TL; DR: In this particular case, I don't see much backward
 > compatibility, so yes, let's add them.

 > So it would not likely break much at all if they were added. (and
 > I'm still confused why they aren't there in the firs place, the PEP
 > doesn't seem very clear about it)

Why do you want to add them?  The point of an ABC is that it is
Abstract.  This doesn't just mean "can't instantiate", it also means
"only the defining features."

 > BUT: This *may* be a different case -- the Set ABC (and set
 > duck-typing) is probably far less used than for Sequences.

I don't know about the Set ABC, but duck-typing is presumably quite
common.  {1}.union([2]) uses set duck-typing.  Presumably if self is a
set, .union (and .intersection) works on any Sized: all you need
mathematically is the ability to iterate the argument, and practically
you'd like to have len() so you can avoid infloops.  The other thing
you need mathematically to have a set is the 'in' operation.  If
mutable, you need an idempotent .add, and .remove.

Of course convenience counts.  It's not obvious to me whether the
convenience of having those methods outweighs the parsimony of only
implementing the dunders.  In fact, it's not obvious to me whether
there's *any* convenience to having those methods.  Shouldn't we want
to encourage the use of the more concise and less cluttered operators,
which also have the advantage that either operand can provide the
implementation?

OK, sometimes that may not be an advantage.  But even if you want to
specify which operand will provide the implementation, you can use the
explicit dunder.  In that case I agree the named operations are more
readable, but how often are you going to do that (for that purpose)?

 > And while the proposed methods are not part of the Set ABC at this
 > point, they ARE part of the build in set object. And historically
 > at least, people informally duck typed as often, or more often,
 > than they subclassed from or registered with ABCs anyway.

If you want all of the methods of the built-in set, use it or derive
from it, or construct one.

 > And even if they are not added to the ABC, they could still be
 > added to the other set-like objects in the standard library -- are
 > there any other than the dict views?

What's the point?  You want to add "There should be two-- and
preferably exactly two --obvious ways to do it" to the Zen?
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BBU6LGUPJSGWEYFFNSBHP2JPYRHL7IMW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to