The numbers module provides very useful ABC for the 'numeric tower', able to
abstract away the differences between python primitives and for example numpy
primitives.
I could not find any equivalent for Booleans.
However numpy defines np.bool too, so being able to have an abstract Boolean
class
On Mon, Feb 12, 2018 at 09:41:04AM +, Sylvain MARIE wrote:
> The numbers module provides very useful ABC for the 'numeric tower',
> able to abstract away the differences between python primitives and
> for example numpy primitives.
> I could not find any equivalent for Booleans.
> However nu
TBH I've found the numeric tower a questionable addition to Python's
stdlib. For PEP 484 we decided not to use it (using the concrete types,
int, float etc. instead). So I'm not excited about adding more like this,
especially since essentially *everything* can be used in a Boolean context.
If your
NumPy np.bool_ is specifically not a subclass of any np.int_. If it we're,
there would be an ambiguity between indexing with a Boolean array and an
array of ints. Both are meaningful, but they mean different things (mask vs
collection of indices).
Do we have other examples a Python ABC that exist
On 13 February 2018 at 02:14, David Mertz wrote:
> NumPy np.bool_ is specifically not a subclass of any np.int_. If it we're,
> there would be an ambiguity between indexing with a Boolean array and an
> array of ints. Both are meaningful, but they mean different things (mask vs
> collection of in
I'm not sure I'm convinced by Sylvain that Boolean needs to be an ABC in
the standard library; Guido expresses skepticism. Of course it is possible
to define it in some other library that actually needs to use
`isinstance(x, Boolean)` as Sylvain demonstraits in his post. I'm not sure
I'm unconvin