MCPcopy Index your code
hub / github.com/python/cpython / __new__

Method __new__

Lib/zoneinfo/_zoneinfo.py:40–56  ·  view source on GitHub ↗
(cls, key)

Source from the content-addressed store, hash-verified

38 cls._weak_cache = weakref.WeakValueDictionary()
39
40 def __new__(cls, key):
41 instance = cls._weak_cache.get(key, None)
42 if instance is None:
43 instance = cls._weak_cache.setdefault(key, cls._new_instance(key))
44 instance._from_cache = True
45
46 # Update the "strong" cache
47 cls._strong_cache[key] = cls._strong_cache.pop(key, instance)
48
49 if len(cls._strong_cache) > cls._strong_cache_size:
50 try:
51 cls._strong_cache.popitem(last=False)
52 except KeyError:
53 # another thread may have already emptied the cache
54 pass
55
56 return instance
57
58 @classmethod
59 def no_cache(cls, key):

Callers 2

_new_instanceMethod · 0.45
from_fileMethod · 0.45

Calls 5

_new_instanceMethod · 0.80
getMethod · 0.45
setdefaultMethod · 0.45
popMethod · 0.45
popitemMethod · 0.45

Tested by

no test coverage detected