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 iterab

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 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 accept any iterable as an >

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 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, and index tupl

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

2010-09-29 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, s

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

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'

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 RightThingToDo(

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 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 t

[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: Binar