When calling numpy.array in the following two ways:
>>> np.array((1,2,3,4))
array([1, 2, 3, 4])
>>> np.array([1,2,3,4])
array([1, 2, 3, 4])
I notice it returns two seemingly identical ndarrays. Are both of these ndarrays identical? Why?
We can behave in a general way here. Suppose we don't know what X = np.array([1,2,3,4]) and Y = np.array((1,2,3,4)) are. If we print it, we can see an output which is the result of a secret built-in methods X.__repr__ and Y.__repr__. You can see here for sure that both X and Y has the same representations. It doesn't mean, however, that they are the same because they can be instances of different classes with the same representations. To make it sure, I usually use X.__class__ and Y.__class__. So both X and Y are instances of the same class np.ndarray.
compound dtype(to make astructuredarray) they have different meanings. See my recent answer for example: stackoverflow.com/questions/60174899/…