Why flatten() is slower than ravel() function in reshaping arrays in python?
x = np.arange(1000000)
x.shape = 100, 100, 100
%timeit x.flatten()
%timeit x.ravel()
NumPy offers many functions and some of them can produce same results I think it depends on being Inplace and not.
numpyfunctions or methods that work in-place. But there is an important distinction between aviewandcopy. Operations that return views are faster.ravelis one; it is essentially areshape. But sometimes even those have to return copies. Don't skip the officialnumpydocs, especially the beginners and essentials parts. And then keep the reference section handy for continual reference.