MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / memorized_timedelta

Function memorized_timedelta

tests/test_code/py/pytz/tzinfo.py:18–25  ·  view source on GitHub ↗

Create only one instance of each distinct timedelta

(seconds)

Source from the content-addressed store, hash-verified

16
17
18def memorized_timedelta(seconds):
19 '''Create only one instance of each distinct timedelta'''
20 try:
21 return _timedelta_cache[seconds]
22 except KeyError:
23 delta = timedelta(seconds=seconds)
24 _timedelta_cache[seconds] = delta
25 return delta
26
27_epoch = datetime.utcfromtimestamp(0)
28_datetime_cache = {0: _epoch}

Callers 4

build_tzinfoFunction · 0.90
memorized_ttinfoFunction · 0.85
tzinfo.pyFile · 0.85
unpicklerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected