-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove superfluous hashing from pickle core.
- Loading branch information
Showing
1 changed file
with
3 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
# Licensed under the MIT license: | ||
# http://www.opensource.org/licenses/MIT-license | ||
# Copyright (c) 2016, Shay Palachy <[email protected]> | ||
import hashlib | ||
import os | ||
import pickle # for local caching | ||
from datetime import datetime | ||
|
@@ -139,7 +138,7 @@ def _get_cache(self): | |
def _get_cache_by_key(self, key=None, hash=None): | ||
fpath = self._cache_fpath() | ||
if hash is None: | ||
fpath += f'_{hashlib.sha256(pickle.dumps(key)).hexdigest()}' | ||
fpath += f'_{key}' | ||
else: | ||
fpath += f'_{hash}' | ||
try: | ||
|
@@ -174,7 +173,7 @@ def _save_cache(self, cache, key=None, hash=None): | |
self.cache = cache | ||
fpath = self._cache_fpath() | ||
if key is not None: | ||
fpath += f'_{hashlib.sha256(pickle.dumps(key)).hexdigest()}' | ||
fpath += f'_{key}' | ||
elif hash is not None: | ||
fpath += f'_{hash}' | ||
with portalocker.Lock(fpath, mode='wb') as cache_file: | ||
|
@@ -249,8 +248,7 @@ def mark_entry_not_calculated(self, key): | |
def wait_on_entry_calc(self, key): | ||
if self.separate_files: | ||
entry = self._get_cache_by_key(key) | ||
hexdg = hashlib.sha256(pickle.dumps(key)).hexdigest() | ||
filename = f'{self._cache_fname()}_{hexdg}' | ||
filename = f'{self._cache_fname()}_{key}' | ||
else: | ||
with self.lock: | ||
self._reload_cache() | ||
|