0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Qiita全国学生対抗戦Advent Calendar 2024

Day 18

pythonでfunctoolsのlru_casheのまねごとをした

Posted at

こんな感じで作った

my_cashe.py
def my_lru_cache(func):
    precomputed = dict()
    def wrapper(*args, **kwargs):
        tmp = (args,tuple(kwargs.items()))
        if not tmp in precomputed.keys():
            precomputed[tmp] = func(*args, **kwargs)
        return precomputed[tmp]
    return wrapper

lruは実装していない
講義の一環で作る機会があったから投稿してみた

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?