Does ufunc functions operate on only ndarray objects

Hi,
I’m new to python language and was reading about ufunc functions from NumPy. As per definition it says,
" ufuncs stands for “Universal Functions” and they are NumPy functions that operate on the ndarray object."

But in below example ufunc function is used on a list which is not a ndarray object,

import numpy as np

x = [1, 2, 3, 4]
y = [4, 5, 6, 7]
z = np.add(x, y)

print(z)

As per definition if it can operate only on ndarray objects then how it can operate on list(which is not ndarray object) ??

ufuncs don’t require their inputs to already be arrays. They’ll happily accept any “array like” objects, and will implicitly convert non-array arguments to arrays.

In numpy’s docs, this is indicated by a parameter having the type array_like. Parameters that need to be given actual ndarray instances are documented as having type ndarray.

3 Likes