Skip to content

Commit 191aa9c

Browse files
committed
touched up comments
1 parent f2f70a6 commit 191aa9c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pydra/utils/hash.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,12 @@ def calc_hash(first: ty.Optional[bytes] = None) -> Hash:
242242
h.update(chunk)
243243
return Hash(h.digest())
244244

245-
# Read the first chunk of the bytes_repr iterator, check to see whether it returns
246-
# a "cache-key" tuple instead of a bytes chunk for the type of the object to cache
245+
# Read the first item of the bytes_repr iterator, check to see whether it returns
246+
# a "cache-key" tuple instead of a bytes chunk for the type of the object to be cached
247247
# (i.e. file objects). If it does use that key to check the persistent cache for
248-
# a precomputed hash and otherwise calculate the hash and store it in the
249-
# persistent cache with that key.
250-
251-
# If the first chunk is a bytes chunk (i.e. the object type doesn't have an associated
252-
# 'cache-key'), then simply calculate the hash of the object.
248+
# a precomputed hash and return it if it is, otherwise calculate the hash and
249+
# store it in the persistent cache with that hash of that key (not to be confused
250+
# with the hash of the object that is saved/retrieved).
253251
first = next(bytes_it)
254252
if isinstance(first, tuple):
255253
tp = type(obj)
@@ -259,6 +257,10 @@ def calc_hash(first: ty.Optional[bytes] = None) -> Hash:
259257
) + first
260258
hsh = cache.persistent.get_or_calculate_hash(key, calc_hash)
261259
else:
260+
# If the first item is a bytes chunk (i.e. the object type doesn't have an
261+
# associated 'cache-key'), then simply calculate the hash of the object,
262+
# passing the first chunk to the `calc_hash` function so it can be included
263+
# in the hash calculation
262264
hsh = calc_hash(first=first)
263265
logger.debug("Hash of %s object is %s", obj, hsh)
264266
cache[objid] = hsh

0 commit comments

Comments
 (0)