traffic.core.cache
- traffic.core.cache.cache_results(fun=None, cache_path=PosixPath('.'), loader=<function read_pickle>, pd_varnames=False)
The point of this method is to be able to cache results of some costly functions on
pd.DataFrame,FlightorTrafficstructures.Decorate your function with the cache_results method and go ahead!
- Parameters:
fun (
Optional[Callable[...,TypeVar(T,DataFrame, Traffic, Flight)]]) – the function to decoratecache_path (
Path) – (default: current directory) where to store the resultsloader (
Callable[[Path],TypeVar(T,DataFrame, Traffic, Flight)]) – (default:pd.read_pickle()) the function used to load the data from a cache filepd_varnames (
bool) – (default: False) when True, try to use the name of the local variable as a cache key
- Return type:
Callable[[Callable[...,TypeVar(T,DataFrame, Traffic, Flight)]],Union[TypeVar(T,DataFrame, Traffic, Flight),Callable[...,TypeVar(T,DataFrame, Traffic, Flight)]]]
- traffic.core.cache.property_cache(method)
Computes attribute value and caches it in the instance.
Reference: Python Cookbook (Denis Otkidach)This decorator allows you to create a property which can be computed once and accessed many times. Sort of like memoization, but by instance.