diff --git a/pymbolic/mapper/__init__.py b/pymbolic/mapper/__init__.py
index eddea8de75a0df9adf2bda553fd3563117691775..8721f42b5600c7a9b3e603459eb782b5ec9a4c72 100644
--- a/pymbolic/mapper/__init__.py
+++ b/pymbolic/mapper/__init__.py
@@ -23,6 +23,7 @@ THE SOFTWARE.
 from abc import ABC, abstractmethod
 from typing import Any, Dict
 import pymbolic.primitives as primitives
+import immutables
 
 __doc__ = """
 Basic dispatch
@@ -251,7 +252,7 @@ class CachedMapper(Mapper):
         # 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(
diff --git a/setup.py b/setup.py
index e0d5f35dce614d4c33682b7eddecd5ea09cdac48..fd03f559b8f59245cd9fb7d243abb1a2eca3d678 100644
--- a/setup.py
+++ b/setup.py
@@ -38,6 +38,7 @@ setup(name="pymbolic",
       python_requires="~=3.8",
       install_requires=[
           "pytools>=2022.1.14",
+          "immutables",
           ],
       extras_require={
           "test": ["pytest>=2.3"],