コード例 #1
0
ファイル: caching.py プロジェクト: shivam14300/hydro-drought
 def __init__(self, py_func, py_file):
     self._py_file = py_file
     self._lineno = py_func.__code__.co_firstlineno
     appdirs = AppDirs(appname="numba", appauthor=False)
     cache_dir = appdirs.user_cache_dir
     cache_subpath = self.get_suitable_cache_subpath(py_file)
     self._cache_path = os.path.join(cache_dir, cache_subpath)
コード例 #2
0
 def __init__(self, py_func, py_file):
     self._py_file = py_file
     self._lineno = py_func.__code__.co_firstlineno
     appdirs = AppDirs(appname="numba", appauthor=False)
     cache_dir = appdirs.user_cache_dir
     cache_subpath = os.path.dirname(py_file)
     if not (os.name == "nt" or getattr(sys, "frozen", False)):
         # On non-Windows, further disambiguate by appending the entire
         # absolute source path to the cache dir, e.g.
         # "$HOME/.cache/numba/usr/lib/.../mypkg/mysubpkg"
         # On Windows, this is undesirable because of path length limitations
         # For frozen applications, there is no existing "full path"
         # directory, and depends on a relocatable executable.
         cache_subpath = os.path.abspath(cache_subpath).lstrip(os.path.sep)
     self._cache_path = os.path.join(cache_dir, cache_subpath)
コード例 #3
0
ファイル: caching.py プロジェクト: cmaclell/numbert
import sys, os
import hashlib
import timeit
from types import FunctionType
#Snatch AppDirs from numba numba and find the cache dir
from numba.misc.appdirs import AppDirs

# from numbert.core import Add
appdirs = AppDirs(appname="numbert", appauthor=False)
cache_dir = appdirs.user_cache_dir


class _UniqueHashable():
    @classmethod
    def get_hashable(cls):
        raise NotImplemented()


def update_unique_hash(m, obj):
    if (isinstance(obj, str)):
        m.update(obj.encode('utf-8'))
    elif (isinstance(obj, (tuple, list))):
        for i, x in enumerate(obj):
            update_unique_hash(m, i)
            update_unique_hash(m, x)
    elif (isinstance(obj, dict)):
        for k, v in obj.items():
            update_unique_hash(m, k)
            update_unique_hash(m, v)
    elif (isinstance(obj, FunctionType)):
        m.update(obj.__code__.co_code)