]>
Commit | Line | Data |
---|---|---|
0b9c08b4 | 1 | # flake8: noqa: F405 |
2 | from functools import * # noqa: F403 | |
3 | ||
4 | from .compat_utils import passthrough_module | |
5 | ||
6 | passthrough_module(__name__, 'functools') | |
7 | del passthrough_module | |
8 | ||
9 | try: | |
10 | cache # >= 3.9 | |
11 | except NameError: | |
12 | cache = lru_cache(maxsize=None) | |
2762dbb1 | 13 | |
14 | try: | |
15 | cached_property # >= 3.8 | |
16 | except NameError: | |
17 | class cached_property: | |
18 | def __init__(self, func): | |
19 | update_wrapper(self, func) | |
20 | self.func = func | |
21 | ||
22 | def __get__(self, instance, _): | |
1a8cc837 | 23 | if instance is None: |
24 | return self | |
2762dbb1 | 25 | setattr(instance, self.func.__name__, self.func(instance)) |
26 | return getattr(instance, self.func.__name__) |