Skip to Content
NumPy Essentials
book

NumPy Essentials

by Jaidev Deshpande, Leo (Liang-Huan) Chin, Tanmay Dutta, Shane Holloway
April 2016
Beginner content levelBeginner
156 pages
3h 23m
English
Packt Publishing
Content preview from NumPy Essentials

Memory layout of ndarray

A particularly interesting attribute of the ndarray object is flags. Type the following code:

In [12]: x.flags 

It should produce something like this:

Out[12]: 
  C_CONTIGUOUS : True 
  F_CONTIGUOUS : False 
  OWNDATA : True 
  WRITEABLE : True 
  ALIGNED : True 
  UPDATEIFCOPY : False 

The flags attribute holds information about the memory layout of the array. The C_CONTIGUOUS field in the output indicates whether the array was a C-style array. This means that the indexing of this array is done like a C array. This is also called row-major indexing in the case of 2D arrays. This means that, when moving through the array, the row index is incremented first, and then the column index is incremented. In the case of a multidimensional C-style ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SciPy and NumPy

SciPy and NumPy

Eli Bressert
Python Distilled

Python Distilled

David M. Beazley

Publisher Resources

ISBN: 9781784393670Supplemental Content