def _index_key(self, sig, codegen): """ Compute index key for the given signature and codegen. It includes a description of the OS, target architecture and hashes of the bytecode for the function and, if the function has a __closure__, a hash of the cell_contents. """ codebytes = self._py_func.__code__.co_code cvars = self._get_dependencies(self._py_func) if len(cvars) > 0: cvarbytes = dumps(cvars) else: cvarbytes = b'' return (sig, "libertem-numba-cache", codegen.magic_tuple(), (hasher(codebytes), hasher(cvarbytes),))
def _index_key(self, sig, codegen): """ Compute index key for the given signature and codegen. It includes a description of the OS, target architecture and hashes of the bytecode for the function and, if the function has a __closure__, a hash of the cell_contents. """ codebytes = self._py_func.__code__.co_code if self._py_func.__closure__ is not None: cvars = tuple([x.cell_contents for x in self._py_func.__closure__]) cvarbytes = dumps(cvars) else: cvarbytes = b'' hasher = lambda x: hashlib.sha256(x).hexdigest() return (sig, codegen.magic_tuple(), (hasher(codebytes), hasher(cvarbytes),))
def _index_key(self, sig, codegen): """ Compute index key for the given signature and codegen. It includes a description of the OS, target architecture and hashes of the bytecode for the function and, if the function has a __closure__, a hash of the cell_contents. """ codebytes = self._py_func.__code__.co_code if self._py_func.__closure__ is not None: cvars = tuple([x.cell_contents for x in self._py_func.__closure__]) # Note: cloudpickle serializes a function differently depending # on how the process is launched; e.g. multiprocessing.Process cvarbytes = dumps(cvars) else: cvarbytes = b'' hasher = lambda x: hashlib.sha256(x).hexdigest() return (sig, codegen.magic_tuple(), (hasher(codebytes), hasher(cvarbytes),))
def _dump(self, obj): return dumps(obj)