I have seen questions similar to this, but not one directly addressing the issue. I have timed the following two ways of populating the array and half the time using np.zeros() is faster and half the time doing it directly is faster. Is there a preferable way? I am quite new to using numpy arrays, and have gotten involved with the aim of speeding up my code rather without too much thought to readability.
import numpy as np
import time
lis = range(100000)
timer = time.time()
list1 = np.array(lis)
print 'normal array creation', time.time() - timer, 'seconds'
timer = time.time()
list2 = np.zeros(len(lis))
list2.fill(lis)
print 'zero, fill - array creation', time.time() - timer, 'seconds'
Thank you
timeitmodule.