Longest increasing path in a grid

grid is a list of lists of whole numbers. Write longest_path(grid) that returns the number of cells in the longest path that moves up, down, left or right and strictly increases at every step.

longest_path([[9, 9, 4], [6, 6, 8], [2, 1, 1]])  ->  4     (1, 2, 6, 9)
longest_path([[3, 4, 5], [3, 2, 6], [2, 2, 1]])  ->  4
longest_path([[1]])                              ->  1

Depth-first search from each cell with memoisation of "longest path starting here". No visited set is needed: strictly increasing means no cycles.

def longest_path(grid):
    ...