Tag Archives: LRU-cache

LRU cache solution: a case for linked lists in Python

The reason I put up the LRU cache challenge up, was that I couldn’t think of a good solution to the problem without using linked lists. This has been pointed to by Adam and Erez as well. Adam commented on … Continue reading

Posted in Challenges, Design, Programming, Python | Tagged , , | 3 Comments

Small Python Challenge No. 2 – LRU Cache

Caching is easy. Consider the cache I used to optimize the recursive spring: class _NotInDict(object): pass _NotInDict = _NotInDict() def cached(func): cache = {} def wrapper_func(*args): prev_result = cache.get(args, _NotInDict) if prev_result is _NotInDict: result = func(*args) cache[args] = result … Continue reading

Posted in Algorithms, Challenges, computer science, Programming, Python, Utility Functions | Tagged , , | 2 Comments