This file contains 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
import random | |
class MutableCounter: | |
""" | |
Used by "count_calls". | |
""" | |
n = 0 | |
def inc(self): | |
self.n += 1 |
This file contains 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 typing import Callable, Iterable, TypeVar, Iterator, Optional | |
A = TypeVar("A") | |
def some(pred: Callable[[A], bool], seq: Iterable[A]) -> Optional[A]: | |
""" | |
Returns the first item in "seq" that satisfies "pred". | |
Examples: |
This file contains 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 datetime import datetime as dt | |
from croniter import croniter | |
from functools import wraps | |
from typing import Dict, Any | |
def cache_with_schedule(schedule: str): | |
""" | |
Decorator to cache the results of a function "f(x)" and clear the cache as | |
scheduled. |
OlderNewer