Slices time complexity
Fabien
fabien.maussion at gmail.com
Mon May 18 15:54:20 EDT 2015
On 05/18/2015 09:49 PM, Ian Kelly wrote:
> It may be possible that lists in CPython could be made to share their
> internal arrays with other lists on a copy-on-write basis, which could
> allow slicing to be O(1) as long as neither list is modified while the
> array is being shared. I expect this would be a substantial piece of
> work, and I don't know if it's something that anybody has looked into.
Isn't Numpy doing this (not sure, not a python nor a numpy expert):
>>> import numpy as np
>>> a = np.array([1,2,3,4])
>>> b = a[1:]
>>> b[0] = 9
>>> a
array([1, 9, 3, 4])
Fabien
More information about the Python-list
mailing list