> On 13 Dec 2020, at 6:25 am, Sebastian Berg <sebast...@sipsolutions.net> wrote:
> 
> But "default" in NumPy really doesn't mean a whole lot?  I can think of
> three places where "defaults" exists:

Huh? There are platform-specific defaults for literally every array creation 
function in NumPy?

In [1]: np.array([4, 9]).dtype
Out[1]: dtype('int64')

In [2]: np.array([3., 0.]).dtype
Out[2]: dtype('float64')

In [3]: np.arange(5).dtype
Out[3]: dtype('int64')

In [4]: np.arange(5.).dtype
Out[4]: dtype('float64')

In [5]: np.empty(5).dtype
Out[5]: dtype('float64')

In [6]: np.zeros(5).dtype
Out[6]: dtype('float64')

In [7]: np.full(5, 5).dtype
Out[7]: dtype('int64')

In [8]: np.full(5, 5.).dtype
Out[8]: dtype('float64’)

The list goes on…

And, indeed, mixing types can cause implicit casting, and thus both slowness 
and unexpected type promotion, which brings with it its own bugs… Again, I 
think it is valuable to have syntax to express `np.zeros(…, 
dtype=<whatever-dtype-np.array(…)-would-give-for-my-data>)`.

Juan.
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to