Skip to content

Commit

Permalink
Remove superfluous hashing from pickle core.
Browse files Browse the repository at this point in the history
  • Loading branch information
lordjabez committed Apr 3, 2023
1 parent b0e65ce commit 7bd2c77
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cachier/pickle_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2016, Shay Palachy <shaypal5@gmail.com>
import hashlib
import os
import pickle # for local caching
from datetime import datetime
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7bd2c77

Please sign in to comment.