MCPcopy Create free account
hub / github.com/numpy/numpy / __init__

Method __init__

numpy/distutils/ccompiler_opt.py:806–849  ·  view source on GitHub ↗
(self, cache_path=None, *factors)

Source from the content-addressed store, hash-verified

804 _cache_ignore = re.compile("^(_|conf_)")
805
806 def __init__(self, cache_path=None, *factors):
807 self.cache_me = {}
808 self.cache_private = set()
809 self.cache_infile = False
810 self._cache_path = None
811
812 if self.conf_nocache:
813 self.dist_log("cache is disabled by `Config`")
814 return
815
816 self._cache_hash = self.cache_hash(*factors, *self.conf_cache_factors)
817 self._cache_path = cache_path
818 if cache_path:
819 if os.path.exists(cache_path):
820 self.dist_log("load cache from file ->", cache_path)
821 cache_mod = self.dist_load_module("cache", cache_path)
822 if not cache_mod:
823 self.dist_log(
824 "unable to load the cache file as a module",
825 stderr=True
826 )
827 elif not hasattr(cache_mod, "hash") or \
828 not hasattr(cache_mod, "data"):
829 self.dist_log("invalid cache file", stderr=True)
830 elif self._cache_hash == cache_mod.hash:
831 self.dist_log("hit the file cache")
832 for attr, val in cache_mod.data.items():
833 setattr(self, attr, val)
834 self.cache_infile = True
835 else:
836 self.dist_log("miss the file cache")
837
838 if not self.cache_infile:
839 other_cache = _share_cache.get(self._cache_hash)
840 if other_cache:
841 self.dist_log("hit the memory cache")
842 for attr, val in other_cache.__dict__.items():
843 if attr in other_cache.cache_private or \
844 re.match(self._cache_ignore, attr):
845 continue
846 setattr(self, attr, val)
847
848 _share_cache[self._cache_hash] = self
849 atexit.register(self.cache_flush)
850
851 def __del__(self):
852 for h, o in _share_cache.items():

Callers 1

__init__Method · 0.45

Calls 5

cache_hashMethod · 0.95
dist_load_moduleMethod · 0.80
dist_logMethod · 0.45
existsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected