Skip to content

Commit

Permalink
get_cache_key: replace sorted() with immutable Map
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener authored and inducer committed Aug 24, 2023
1 parent a2cf0e8 commit 82220fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pymbolic/mapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from abc import ABC, abstractmethod
from typing import Any, Dict
import pymbolic.primitives as primitives
import immutables

__doc__ = """
Basic dispatch
Expand Down Expand Up @@ -251,7 +252,7 @@ def get_cache_key(self, expr, *args, **kwargs):
# Must add 'type(expr)', to differentiate between python scalar types.
# In Python, the following conditions are true: "hash(4) == hash(4.0)"
# and "4 == 4.0", but their traversal results cannot be re-used.
return (type(expr), expr, args, tuple(sorted(kwargs.items())))
return (type(expr), expr, args, immutables.Map(kwargs))

def __call__(self, expr, *args, **kwargs):
result = self._cache.get(
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
python_requires="~=3.8",
install_requires=[
"pytools>=2022.1.14",
"immutables",
],
extras_require={
"test": ["pytest>=2.3"],
Expand Down

0 comments on commit 82220fe

Please sign in to comment.