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 exists to accommodate something
outside the standard library or builtins? Even if not, NumPy is special...
the actual syntax for '@' exists primarily for that library!

On Feb 12, 2018 5:51 AM, "Steven D'Aprano" <> wrote:

On Mon, Feb 12, 2018 at 09:41:04AM +0000, 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 numpy defines np.bool too, so being able to have an abstract
> Boolean class for both python bool and numpy bool would be great.

I don't know anything about numpy bools, but Python built-in bools are
numbers, and as such already have an ABC: they are a subclass of int.

Python-ideas mailing list
Code of Conduct:
Python-ideas mailing list
Code of Conduct:

Reply via email to