Is arr.__len__() the preferred way to get the length of an array in Python?
No, in python the built-in len()
function is the preferred way to get the length of an array, list or any other iterable object. len(arr)
returns the number of elements in the array. The __len__()
method is used by the built-in len()
function to determine the length of an object, but calling it directly on the object is not the usual way. Also the len built-in function is faster than the len() method