A time-space tradeoff exchanges memory for computation. An extended board stores copied boundary cells so the core loop avoids boundary-condition tests and can run faster. section 5.6.1
Evaluate the tradeoff against the whole implementation:
- Allocate an extended board when removing repeated boundary tests simplifies or accelerates the core algorithm. section 5.6.1
- Account for the cost of copying the original board and storing the larger array; available memory and algorithmic costs determine whether the exchange pays off. section 5.6.1
- Treat disabled wraparound and bounds checks as related performance choices: they remove CPython or verification overhead but restrict convenient indexing idioms. section 5.6.1
def live(cnp.ndarray[cnp.uint8_t, ndim=2] old_world):
cdef int size_y = old_world.shape[0]
cdef int size_x = old_world.shape[1]
cdef cnp.ndarray[cnp.uint8_t, ndim=2] extended_world =
np.empty((size_y + 2, size_x + 2), dtype=np.uint8) # empty
cdef cnp.ndarray[cnp.uint8_t, ndim=2] new_world =
np.empty((size_y, size_x), np.uint8)
cdef cnp.ndarray[cnp.uint8_t, ndim=1] states = np.empty((5,), np.uint8)
live_core(old_world, extended_world, new_world, states)
return new_world
Inspect the Cython function that allocates the extended and output boards before delegating to the optimized core loop. section 5.6.1

