python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

deepcopy is slow

Open dizcza opened this issue 5 years ago • 0 comments

Neo DataObject has the __deepcopy__ function, but it's slow, compared to cloning the array only:

from copy import deepcopy
sts = [elephant.spike_train_generation.homogeneous_poisson_process(rate=10*pq.Hz, t_stop=1*pq.s) for _ in range(1000)]
%timeit deepcopy(sts)
191 ms ± 14.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%timeit [st.copy() for st in sts]
3.15 ms ± 500 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

dizcza avatar Nov 30 '20 09:11 dizcza