[Numpy-discussion] array slicing questions

Nathaniel Smith njs@pobox....
Tue Jul 31 10:43:30 CDT 2012


On Tue, Jul 31, 2012 at 2:23 PM, eat <e.antero.tammi@gmail.com> wrote:
> Apparently ast(.) does not return a view of the original matches rather a
> copy of size (n* (2* distance+ 1)), thus you may run out of memory.

The problem isn't memory, it's that on 32-bit Python,
np.prod(arr.shape) must be <2**32 (or maybe 2**31 -- something like
that). Normally you wouldn't be creating such arrays anyway because
they would be too big to fit into memory, so this problem isn't
observed, but when you're using stride_tricks then it's very easy to
create arrays that use only a small amount of memory but that have
very large shapes. Solution: don't buy more memory, just use a 64-bit
Python, where the limit is 2**64 (or 2**63 or whatever).

-n


More information about the NumPy-Discussion mailing list