2024-heraklion-comp-arch/numpy
2024-08-13 13:45:05 +02:00
..
ndarray-memory-layout-1d.svg added numpy diagrams 2024-08-13 13:45:05 +02:00
ndarray-memory-layout-2d-rectangular.svg added numpy diagrams 2024-08-13 13:45:05 +02:00
ndarray-memory-layout-2d-square.svg added numpy diagrams 2024-08-13 13:45:05 +02:00
python-list-memory-layout.svg added numpy diagrams 2024-08-13 13:45:05 +02:00
README.md add note about memmap 2024-08-13 13:44:19 +02:00

Anatomy of a numpy array

one dimension, float64

1d array

two dimensions, square, float64

2d array - square

two dimensions, rectangular, int32

2d array - rectangular

what about Python lists?

memory layout of a Python list

interesting attributes of numpy arrays

  • x.data, x.data.hex(), x.data.format, x.tobytes()
  • x.flags:
    • OWNDATA
    • C_CONTIGUOUS
    • F_CONTIGUOUS
    • more flags

If your arrays are bigger than RAM

  • numpy.memmap: an array-like object that maps memory to an array stored on disk, used for accessing small segments of large files on disk, without reading the entire file into memory. Use with caution!

  • HDF5: hierarchical data format, with aribitrary metadata and multilanguage support with h5py with an array-lie interface

  • other projects, for example xarray and zarr