[Numpy-discussion] just how 'discontiguous' can a numpy array become?

Chris Colbert sccolbert@gmail....
Sat Oct 31 07:45:19 CDT 2009


Thanks for the response david.

Lemme rephrase the question a little bit.

It terms of actually memory space, will a numpy array ever point to a
chunk of memory that is not a continually running series of memory
addresses and also not a child of a continuous block of addresses.


Graphically can this every occur in hardware memory:

|--- a portion of array A ---|--- python object foo ---|--- The rest
of array A ----|


The reason I ask is because I am passing numpy arrays into another
library which uses a strided memory model, but not FULLY strided, and
I need to figure out
what checks I need to put in place to ensure that it doesnt trample on
memory. In the best case senario, it would just trample on the parent
array, in the worst case senario it would segfault.

Cheers,

Chris


On Sat, Oct 31, 2009 at 1:32 PM, David Cournapeau <cournape@gmail.com> wrote:
> On Sat, Oct 31, 2009 at 9:22 PM, Chris Colbert <sccolbert@gmail.com> wrote:
>
>>
>> Will there ever be a situation where a discontiguous array owns its
>> own data? Or more generally, will discontiguous data alway have a
>> contiguous parent?
>
> Yes to Q1 and No to Q2.
>
> Discontiguous arrays are very easy to create: for example, if you say
> np.empty((10, 50), order="F"), you have a discontiguous array. I use
> this quite often when I need to interoperate with C or Fortran
> libraries - interoperation with other libraries/formats is another
> common source of discontiguous arrays, compared to memory views.
>
> David
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list