Add an expression restrict cache

To improve performance on big computations, save the values of
restrictions this expression has already performed.

Currently using a regular 'dict' for the cache itself. If we ever hit a
limit on the amount of memory required for a computation, probably will
have to change this to an LRU memory, or use weak references.