A โbasic memory structure" refers to the sequence of octets that make up an object in computer memory. For example, when creating the string "abc" , Python must reserve at least 3 bytes of memory and store the letters a , b and c . If the memory is contiguous (as is the case with strings), its address and size can be passed to any piece of C code that wants to check it without going through overhead like Python str .
A useful example is the type array . An array is a sequence that works the same as a Python list, with the difference that it contains elements of the same type โ you can have an int array and an array of floats, but you cannot mix them. The advantage is that arrays pack the data as efficiently as possible, storing them in a flat array C. This array is displayed through the buffer interface - it allows you to request the exact position and size of the cell underlying the array C and pass it to some function C, which will effectively initialize it or burn it to disk. The numpy numeric package is built around such data exchange between Python and C (and even FORTRAN) for which they extended the buffer protocol, and some of these extensions turned it into Python 3.
The mmap object, which provides the Python interface for OS-level memory mapping functionality, also provides a buffer interface. This allows the C-code, which should efficiently access memory, for example, the re module, also work with areas with memory mapping.
source share