Re: [Python-Dev] API for binary operations on Sets

2010-10-04 Thread Larry Hastings
On 09/29/2010 08:50 PM, Raymond Hettinger wrote: 1. Liberalize setobject.c binary operator methods to accept anything registered to the Set ABC and add a backwards incompatible restriction to the Set ABC binary operator methods to only accept Set ABC instances (they currently accept any

Re: [Python-Dev] API for binary operations on Sets

2010-09-30 Thread Raymond Hettinger
On Sep 29, 2010, at 11:11 PM, geremy condra wrote: P.S. I also encountered a small difficulty in implementing #2 that would still need to be resolved if that option is chosen. What's the issue, if you don't mind me asking? IIRC, just commenting-out the Py_AnySet checks in set_or, set_xor,

Re: [Python-Dev] API for binary operations on Sets

2010-09-30 Thread Daniel Stutzbach
On Wed, Sep 29, 2010 at 11:29 PM, Terry Reedy tjre...@udel.edu wrote: Does this violate the Sequence ABC (assuming there is one)? There is a Sequence ABC, but it does not define __add__. It only defines the following methods: __contains__, __getitem__, __iter__, __len__, __reversed__, count,

Re: [Python-Dev] API for binary operations on Sets

2010-09-30 Thread Nick Coghlan
On Thu, Sep 30, 2010 at 1:50 PM, Raymond Hettinger raymond.hettin...@gmail.com wrote: 1a.  Liberalize setobject.c binary operator methods, restrict SetABC methods, and add named methods (like difference, update, etc) that accept any iterable. 2. We could liberalize builtin set objects to

[Python-Dev] API for binary operations on Sets

2010-09-29 Thread Raymond Hettinger
I would like to solicit this group's thoughts on how to reconcile the Set abstract base class with the API for built-in set objects (see http://bugs.python.org/issue8743 ). I've been thinking about this issue for a good while and the RightThingToDo(tm) isn't clear. Here's the situation:

Re: [Python-Dev] API for binary operations on Sets

2010-09-29 Thread geremy condra
On Wed, Sep 29, 2010 at 8:50 PM, Raymond Hettinger raymond.hettin...@gmail.com wrote: I would like to solicit this group's thoughts on how to reconcile the Set abstract base class with the API for built-in set objects (see http://bugs.python.org/issue8743 ).  I've been thinking about this

Re: [Python-Dev] API for binary operations on Sets

2010-09-29 Thread Terry Reedy
On 9/29/2010 11:50 PM, Raymond Hettinger wrote: I would like to solicit this group's thoughts on how to reconcile the Set abstract base class with the API for built-in set objects (see http://bugs.python.org/issue8743 ). I've been thinking about this issue for a good while and the

Re: [Python-Dev] API for binary operations on Sets

2010-09-29 Thread Raymond Hettinger
On Sep 29, 2010, at 11:29 PM, Terry Reedy wrote: I do not understand this. List.__add__ is currently *more* restrictive than set ops in that it will not even accept a 'frozenlist' (aka tuple). Sorry, that should have been __iadd__(). s = range(5) s += 'abc' s [0, 1, 2, 3, 4, 'a', 'b',

Re: [Python-Dev] API for binary operations on Sets

2010-09-29 Thread Jack Diederich
I will say something snarky now and (hopefully) something useful tomorrow. When ABCs went in I was +0 because, like annotations, I was told I wouldn't have to care about them. That said; I do actually care about the set interface and what set-y-ness means for regular duck typing reasons. What