Created
March 1, 2024 13:20
-
-
Save waicampos/54eeef751954a55db865979063383844 to your computer and use it in GitHub Desktop.
Exemplo de cache usando deque. Fonte: Canal Eduardo Mendes - Live de Python #28 Deque e Namedtuple / Collections #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
cache_values = deque(maxlen=3) | |
def cache(func): | |
def inner(*args): | |
cache_values.append(args) | |
return func(*args) | |
return inner | |
@cache | |
def soma(x, y): | |
return x + y | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment