ichor.core.common.functools package
Submodules
ichor.core.common.functools.functools module
- buildermethod(func: F) F
Executes a function on an instance of a class and returns the modified instance. This allows for scenarios where we can initialize a class and call a method (which does not return anything but it does modify the instance) in the same line.
- Parameters:
func – The function to be executed
Note
- Without builder decorator:
t = Test().add() Since the add() method does not return anything, t is None
- With @builder decorator:
t = Test().add() Since the add() method does not return anything, t is an instance of test
Without builder method: t = Test() t.add()
- class cached_property(func)
Bases:
objectA property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- cached_property_ttl
alias of
cached_property_with_ttl
- class cached_property_with_ntimes(ntimes=None)
Bases:
objectA property that is only computed once per instance and then replaces itself with an ordinary attribute. Setting the ntimes to a number expresses how many times the property can be called before being recalculated
- class cached_property_with_ttl(ttl=None)
Bases:
objectA property that is only computed once per instance and then replaces itself with an ordinary attribute. Setting the ttl to a number expresses how long the property will last before being timed out.
- classproperty(func: F) ClassPropertyDescriptor
A decorator which makes it possible to make class properties, where the class can call a class method without the parenthesis at the end. This is useful to have as class variables are static and cannot be changed. Class properties allow us to change these values on the fly.
- get_functions_to_run(obj: Any) Sequence[F]
Finds all methods of obj with the order attribute then returns the sequence of methods in the order defined
- ntimes_cached_property
alias of
cached_property_with_ntimes
- run_function(order: Scalar) F
Used to decorate a method so that get_functions_to_run can find and return the methods in the order specified by the order parameter
- run_once(func: F) F
Decorator which only runs the function the first time it is called and stores the result. If the function is ran another time, the stored result is returned.
- class threaded_cached_property(func)
Bases:
objectA cached_property version for use in environments where multiple threads might concurrently try to access the property.
- threaded_cached_property_ttl
alias of
threaded_cached_property_with_ttl
- class threaded_cached_property_with_ttl(ttl=None)
Bases:
cached_property_with_ttlA cached_property version for use in environments where multiple threads might concurrently try to access the property.
- timed_cached_property
alias of
cached_property_with_ttl
- timed_threaded_cached_property
alias of
threaded_cached_property_with_ttl
Module contents
- buildermethod(func: F) F
Executes a function on an instance of a class and returns the modified instance. This allows for scenarios where we can initialize a class and call a method (which does not return anything but it does modify the instance) in the same line.
- Parameters:
func – The function to be executed
Note
- Without builder decorator:
t = Test().add() Since the add() method does not return anything, t is None
- With @builder decorator:
t = Test().add() Since the add() method does not return anything, t is an instance of test
Without builder method: t = Test() t.add()
- class cached_property(func)
Bases:
objectA property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- classproperty(func: F) ClassPropertyDescriptor
A decorator which makes it possible to make class properties, where the class can call a class method without the parenthesis at the end. This is useful to have as class variables are static and cannot be changed. Class properties allow us to change these values on the fly.
- get_functions_to_run(obj: Any) Sequence[F]
Finds all methods of obj with the order attribute then returns the sequence of methods in the order defined
- ntimes_cached_property
alias of
cached_property_with_ntimes
- run_function(order: Scalar) F
Used to decorate a method so that get_functions_to_run can find and return the methods in the order specified by the order parameter
- run_once(func: F) F
Decorator which only runs the function the first time it is called and stores the result. If the function is ran another time, the stored result is returned.
- class threaded_cached_property(func)
Bases:
objectA cached_property version for use in environments where multiple threads might concurrently try to access the property.
- timed_cached_property
alias of
cached_property_with_ttl
- timed_threaded_cached_property
alias of
threaded_cached_property_with_ttl