On Thu, Dec 12, 2019 at 7:39 PM Steven D'Aprano <st...@pearwood.info> wrote:
> Surely a zero-dimensional array ought to have no elements at all? > If you think of a 1-D array as falling on a line, and a 2-D array as occupying a region of a plane, then the equivalent of a geometric point is a 0-D array. It's not really that useful, but there a a couple minor things you can do: >>> z1 = np.array(33, dtype=np.float16) >>> z2 = np.array(44, dtype=np.float16) >>> (z1 * z2)[...] array(1452., dtype=float16) It's also mutable. Although worrying about a memory allocation on one number is probably silly: >>> z1.itemset(55) >>> z1 array(55., dtype=float16) Getting custom dtypes that aren't available in plain Python is probably the best minor feature. But yes, one could easily do all the same things with 1-D arrays of length one. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
_______________________________________________ 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/EYBLXNM6QWYOOLR33NHAUNPPO5O6DQIA/ Code of Conduct: http://python.org/psf/codeofconduct/