decorators
Class info¶
🛈 DocStrings¶
cache_with_transforms
¶
cache_with_transforms(
*,
arg_transformers: dict[int, Callable[[Any], Any]] | None = None,
kwarg_transformers: dict[str, Callable[[Any], Any]] | None = None
) -> Callable[[Callable[P, R]], Callable[P, R]]
A caching decorator with transformation functions for args and kwargs.
Can be used to make specific args / kwargs hashable. Also adds cache and cache_info objects to the decorated function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arg_transformers
|
dict[int, Callable[[Any], Any]] | None
|
Dict mapping positional args indices to transformer functions |
None
|
kwarg_transformers
|
dict[str, Callable[[Any], Any]] | None
|
Dict mapping kwargs names to transformer functions |
None
|
Returns:
Type | Description |
---|---|
Callable[[Callable[P, R]], Callable[P, R]]
|
A decorator function that caches results based on transformed arguments |
Source code in src/jinjarope/decorators.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
read_file_content
¶
Read and return the content of a file.
Source code in src/jinjarope/decorators.py
74 75 76 77 78 |
|