Is there a difference (in performance for example) when comparing shape and len? Consider the following example:
In [1]: import numpy as np
In [2]: a = np.array([1,2,3,4])
In [3]: a.shape
Out[3]: (4,)
In [4]: len(a)
Out[4]: 4
Quick runtime comparison suggests that there's no difference:
In [17]: a = np.random.randint(0,10000, size=1000000)
In [18]: %time a.shape
CPU times: user 6 µs, sys: 2 µs, total: 8 µs
Wall time: 13.1 µs
Out[18]: (1000000,)
In [19]: %time len(a)
CPU times: user 5 µs, sys: 1 µs, total: 6 µs
Wall time: 9.06 µs
Out[19]: 1000000
So, what is the difference and which one is more pythonic? (I guess using shape).