Skip to content

Commit

Permalink
Improve cache hits for tuple keys in key_split and intern results (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter authored Oct 6, 2023
1 parent 62dbbff commit 928a95a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dask/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1851,10 +1851,11 @@ def key_split(s):
>>> key_split('_(x)') # strips unpleasant characters
'x'
"""
# If we convert the key, recurse to utilize LRU cache better
if type(s) is bytes:
s = s.decode()
return key_split(s.decode())
if type(s) is tuple:
s = s[0]
return key_split(s[0])
try:
words = s.split("-")
if not words[0][0].isalpha():
Expand All @@ -1873,7 +1874,7 @@ def key_split(s):
else:
if result[0] == "<":
result = result.strip("<>").split()[0].split(".")[-1]
return result
return sys.intern(result)
except Exception:
return "Other"

Expand Down

0 comments on commit 928a95a

Please sign in to comment.