On Dec 12, 2019, at 16:40, Steven D'Aprano <st...@pearwood.info> wrote:
> 
> 
> Surely a zero-dimensional array ought to have no elements at all?

Forgetting about the practical benefits of having a way to have scalars that 
have a dtype and respond to ndarray methods and so on, here’s how to convince 
yourself it makes sense mathematically:

What do you get when you multiply no numbers together? The multiplicative 
identity, 1.

It’s the same reason that anything to the zeroth power is 1. In fact, it’s 
directly related. A 3D array where all 3 dimensions are 4 has 4**3 elements. A 
matrix where both dimensions are 4 has 4**2 elements. A vector where the sole 
dimension is 4 has 4**1 elements. A scalar where all zero of the dimensions are 
4 has 4**0 elements. And if you’re thinking, hey, can’t you also say that all 
zero of the dimensions are 137? Sure, and the scalar also has 137**0 elements. 
You can say all zero of the dimensions are any number you like, and you get 
that number to the zeroth power elements, which is always 1.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7E744N3CLAQRMM2KSVVBSXQLWHUEF7SH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to