toil.lib.memoize¶
Attributes¶
Memoize a function result based on its parameters using this decorator. |
|
Functions¶
|
Like memoize, but guarantees that decorated function is only called once, even when multiple |
Parses an ISO time with a hard-coded Z for zulu-time (UTC) at the end. Other timezones are |
|
|
Variant of bool() that only accepts two possible string values. |
Module Contents¶
- toil.lib.memoize.memoize¶
Memoize a function result based on its parameters using this decorator.
For example, this can be used in place of lazy initialization. If the decorating function is invoked by multiple threads, the decorated function may be called more than once with the same arguments.
- toil.lib.memoize.MAT¶
- toil.lib.memoize.MRT¶
- toil.lib.memoize.sync_memoize(f)[source]¶
Like memoize, but guarantees that decorated function is only called once, even when multiple threads are calling the decorating function with multiple parameters.
- Parameters:
f (Callable[[MAT], MRT])
- Return type:
Callable[[MAT], MRT]
- toil.lib.memoize.parse_iso_utc(s)[source]¶
Parses an ISO time with a hard-coded Z for zulu-time (UTC) at the end. Other timezones are not supported. Returns a timezone-naive datetime object.
- Parameters:
s (str) – The ISO-formatted time
- Returns:
A timezone-naive datetime object
- Return type:
>>> parse_iso_utc('2016-04-27T00:28:04.000Z') datetime.datetime(2016, 4, 27, 0, 28, 4) >>> parse_iso_utc('2016-04-27T00:28:04Z') datetime.datetime(2016, 4, 27, 0, 28, 4) >>> parse_iso_utc('2016-04-27T00:28:04X') Traceback (most recent call last): ... ValueError: Not a valid ISO datetime in UTC: 2016-04-27T00:28:04X