[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Greg Ewing
Chris Angelico wrote: Python's base object has a lot of extremely useful functionality, Yes, I agree that all that stuff is useful. I'm not saying that Python's object type shouldn't have it, just that it's incompatible with having a strict type system. -- Greg

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Oct 1, 2019, at 15:59, Chris Angelico wrote: > >> On Wed, Oct 2, 2019 at 8:51 AM Greg Ewing >> wrote: >> >> Chris Angelico wrote: >>> The question then would be: why is object() not hashable? >> >> It's not hashable because it's supposed to be the ultimate >> base type for all other object

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Steven D'Aprano
On Tue, Oct 01, 2019 at 09:47:56AM -0700, Andrew Barnert via Python-ideas wrote: > On Oct 1, 2019, at 06:23, Richard Musil wrote: > > > > Where *virtual* is a hyperlink to an ABC definition. > > > > `issubclass` will be fine without virtual and I am not sure why > > virtual has been added to it

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Oscar Benjamin
On Tue, 1 Oct 2019 at 11:24, Steven D'Aprano wrote: > > On Mon, Sep 30, 2019 at 06:00:44PM +0900, Stephen J. Turnbull wrote: > > > Technical questions: does "Subscriptable" mean non-negative ints only, > > or does it include the negative "count from the end" protocol? How > > about slices? > > It

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Oct 1, 2019, at 16:01, Christopher Barker wrote: > > > But I can’t see an argument that something called Subscriptable could (or > > should) actually mean indexable rather than subscriptable. > > Now we are getting into naming things, which is hard, but not the critical > step. > > But as

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Oct 1, 2019, at 12:17, Ben Rudiak-Gould wrote: > >> On Tue, Oct 1, 2019 at 9:26 AM Andrew Barnert wrote: >>> On Sep 30, 2019, at 23:46, Ben Rudiak-Gould wrote: >>> ABC membership is a subtype relationship in some sense, and ordinary Python >>> subclassing is a subtype relationship in some s

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Christopher Barker
> But I can’t see an argument that something called Subscriptable could (or should) actually mean indexable rather than subscriptable. > Now we are getting into naming things, which is hard, but not the critical step. But as you point out, it’s actually not that clear exactly what the OP (or anyo

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Chris Angelico
On Wed, Oct 2, 2019 at 8:51 AM Greg Ewing wrote: > > Chris Angelico wrote: > > The question then would be: why is object() not hashable? > > It's not hashable because it's supposed to be the ultimate > base type for all other objects, and not every object is > hashable. > > It only seems odd if yo

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Greg Ewing
Chris Angelico wrote: The question then would be: why is object() not hashable? It's not hashable because it's supposed to be the ultimate base type for all other objects, and not every object is hashable. It only seems odd if you're used to the idea that you get a bunch of default behaviours

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Oct 1, 2019, at 11:53, Richard Musil wrote: > >> On Tue, Oct 1, 2019 at 6:48 PM Andrew Barnert wrote: > >> Virtual subclassing is key to the way ABCs work. It would be nice if it were >> explained better in the docs, but I suppose usually people don’t need to >> know the details unless the

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Chris Angelico
On Wed, Oct 2, 2019 at 8:29 AM Greg Ewing wrote: > > Chris Angelico wrote: > > The hashability issue is a logical consequence of accepting that the > > above violations are reasonable and practically useful. > > A more principled way to handle this wouild be for object not > to be hashable, and ha

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Greg Ewing
Chris Angelico wrote: The hashability issue is a logical consequence of accepting that the above violations are reasonable and practically useful. A more principled way to handle this wouild be for object not to be hashable, and have another base type for hashable objects. Hashable would then b

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Christopher Barker
On Tue, Oct 1, 2019 at 7:02 AM Greg Ewing wrote: > > >>> issubclass(list, object) > > True > > >>> issubclass(object, collections.abc.Hashable) > > True > > >>> issubclass(list, collections.abc.Hashable) > > False > > This isn't really the fault of

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Chris Angelico
On Wed, Oct 2, 2019 at 5:18 AM Ben Rudiak-Gould wrote: > > On Tue, Oct 1, 2019 at 9:26 AM Andrew Barnert wrote: > > On Sep 30, 2019, at 23:46, Ben Rudiak-Gould wrote: > > > ABC membership is a subtype relationship in some sense, and ordinary > > > Python subclassing is a subtype relationship in

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Ben Rudiak-Gould
On Tue, Oct 1, 2019 at 9:26 AM Andrew Barnert wrote: > On Sep 30, 2019, at 23:46, Ben Rudiak-Gould wrote: > > ABC membership is a subtype relationship in some sense, and ordinary Python > > subclassing is a subtype relationship in some sense, but they aren't quite > > the same sense, > > But in

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Richard Musil
On Tue, Oct 1, 2019 at 6:48 PM Andrew Barnert wrote: > Virtual subclassing is key to the way ABCs work. It would be nice if it > were explained better in the docs, but I suppose usually people don’t need > to know the details unless they’re actually getting involved in something > like designing

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread M.-A. Lemburg
On 30.09.2019 01:41, Steven D'Aprano wrote: > [...] > But subscripting (indexing) is a conspicuous exception. There's no ABC > for testing whether something supports subscripting. +1 for adding an ABC to signal support for indexing. BTW: Something I miss in the ABCs is the distinction between in

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Oct 1, 2019, at 06:23, Richard Musil wrote: > > Where *virtual* is a hyperlink to an ABC definition. > > `issubclass` will be fine without virtual and I am not sure why virtual has > been added to it Virtual subclassing is key to the way ABCs work. It would be nice if it were explained bet

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Andrew Barnert via Python-ideas
On Sep 30, 2019, at 23:46, Ben Rudiak-Gould wrote: > > On Mon, Sep 30, 2019 at 10:08 AM Andrew Barnert via Python-ideas > wrote: >> Also, what we’re checking for really is subtyping. > > Is it? Subtyping in type theory satisfies some axioms, one of which is > transitivity. The addition of the A

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Greg Ewing
On Tue, Oct 1, 2019 at 8:48 AM Ben Rudiak-Gould > wrote: Is it? Subtyping in type theory satisfies some axioms, one of which is transitivity. The addition of the ABCs broke transitivity: >>> issubclass(list, object) True >>> issubclass(

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Richard Musil
On Tue, Oct 1, 2019 at 8:48 AM Ben Rudiak-Gould wrote: > Is it? Subtyping in type theory satisfies some axioms, one of which is > transitivity. The addition of the ABCs broke transitivity: > > >>> issubclass(list, object) > True > >>> issubclass(object, collections.abc.Hashable) >

[Python-ideas] Re: Add Subscriptable ABC

2019-10-01 Thread Steven D'Aprano
On Mon, Sep 30, 2019 at 06:00:44PM +0900, Stephen J. Turnbull wrote: > Technical questions: does "Subscriptable" mean non-negative ints only, > or does it include the negative "count from the end" protocol? How > about slices? It means the class defines a __getitem__ method. Like __call__, the