[SciPy-User] Scipy views and slicing: Can I get a view-slice from only certain elements of an array?
Mon Nov 1 18:51:59 CDT 2010
> >>> l = range(1000)
> >>> sys.getsizeof(l) + len(l)*sys.getsizeof(l)
> >>> a = numpy.arange(1000)
> >>> sys.getsizeof(a) + a.size*a.itemsize
> major difference (unless you are using a numpy array of objects...)
We know the lists are less efficient-- that's why we're using
array.array. You have a good point about array's and lists allocating
a bit extra so they can grow efficiently, but array.array isn't very
large at all
a = array.array("l", range(10000000)) # top reports Virtual = 363m, RES = 323m
a = scipy.array(range(10000000), dtype=scipy.int32) # top reports
Virtual = 371m, RES = 289m
The difference is likely the extra allocated space so that array can grow.
More information about the SciPy-User