It would be good to discuss how memoization could work for the new codebase. The primary advantage would be to avoid creating duplicate instances of the main Diagram and Rewrite data structures. It may also be convenient to be able to cache other expensive quantities, like the slices of a given diagram, the computation of which can otherwise be a bottleneck during rendering. But getting this wrong could easily lead to too much being cached and excessive memory usage.
It would be good to discuss how memoization could work for the new codebase. The primary advantage would be to avoid creating duplicate instances of the main Diagram and Rewrite data structures. It may also be convenient to be able to cache other expensive quantities, like the slices of a given diagram, the computation of which can otherwise be a bottleneck during rendering. But getting this wrong could easily lead to too much being cached and excessive memory usage.