3 ms·
It is interesting that get-slice on list does not use copy-on-write, so it is in fact Theta(k) even if you don't modify the slice.
by praptak 16y ago
It is interesting that get-slice on list does not use copy-on-write, so it is in fact Theta(k) even if you don't modify the slice.
- ot 16y agoCopy on write can be very dangerous if not used properly. Besides concurrency issues (not specifically for python, because of the GIL), in the case of slice taking a small slice from a big list would keep a reference to the list even if it is not needed anymore. In pathological cases this can be as bad as a memory leak.