Slide 15
Slide 15 text
/semut-io /Semutio /semut_io /semut.io
3. Python’s object model can lead to inefficient
memory access
➔ While in C, you might use some buffer based array(pretty fast), Python’s
List is complicated, and clearly, slow.
➔ A NumPy array in its simplest form is a Python object build around a C
array. I.e. it has a pointer to a contiguous data buffer of values.
➔ A Python list, on the other hand, has a pointer to a contiguous buffer of
pointers, each of which points to a Python object which in turn has
references to its data (in this case, integers).
➔ It’s easy to see how numpy substantially boosts the performance.