WayScience / CytoSnake

Orchestrating high-dimensional cell morphology data processing pipelines
https://cytosnake.readthedocs.io
Creative Commons Attribution 4.0 International
3 stars 3 forks source link

Adding Least Recently Used (LRU) caching to pathing functions #76

Open axiomcura opened 1 year ago

axiomcura commented 1 year ago

According to functools documentation implementing lru_cache on function memorizes the output generated.

This means any recursive searches will not be executed again if the output is cached.

It is very simple to implement. Here's an example below:


def test(input: str) -> str:
    # code below
from functools import rlu_cache

@rlu_cache
def test(input: str) -> str:
    #code below

To implement only requires a decorator.