I have quite a large number of data sets to extend.
I'm wondering what would be an alternative/faster way of doing it.
I have tried both iadd and extend, both of them takes quite a while to create an output.
from timeit import timeit
raw_data = [];
raw_data2 = [];
added_data = range(100000)
# .__iadd__
def test1():
for i in range(10):
raw_data.__iadd__(added_data*i);
#extend
def test2():
for i in range(10):
raw_data2.extend(added_data*i);
print(timeit(test1,number=2));
print(timeit(test2,number=2));
I feel the list comprehension or array mapping could be an answer to my question ...