Skip to content

Commit

Permalink
Switch to constantdict
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Feb 3, 2025
1 parent a17580e commit a2ecb3c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"sympy": ("https://docs.sympy.org/dev/", None),
"typing_extensions":
("https://typing-extensions.readthedocs.io/en/latest/", None),
"immutabledict":
("https://immutabledict.corenting.fr/", None)
"constantdict":
("https://matthiasdiener.github.io/constantdict/", None)
}
autodoc_type_aliases = {
"Expression": "Expression",
Expand Down
8 changes: 4 additions & 4 deletions pymbolic/mapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
from warnings import warn

from immutabledict import immutabledict
from constantdict import constantdict
from typing_extensions import ParamSpec, TypeIs

import pymbolic.primitives as p
Expand Down Expand Up @@ -413,7 +413,7 @@ def get_cache_key(self,
# 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, immutabledict(kwargs))
return (type(expr), expr, args, constantdict(kwargs))

def __call__(self,
expr: Expression,
Expand Down Expand Up @@ -760,7 +760,7 @@ def map_call_with_kwargs(self,
parameters = tuple([
self.rec(child, *args, **kwargs) for child in expr.parameters
])
kw_parameters: Mapping[str, Expression] = immutabledict({
kw_parameters: Mapping[str, Expression] = constantdict({
key: self.rec(val, *args, **kwargs)
for key, val in expr.kw_parameters.items()})

Expand Down Expand Up @@ -1517,7 +1517,7 @@ def map_common_subexpression(self,
ccd = self._cse_cache_dict = {}

key: tuple[Expression, P.args, P.kwargs] = (
expr, args, immutabledict(kwargs))
expr, args, constantdict(kwargs))
try:
return ccd[key]
except KeyError:
Expand Down
4 changes: 2 additions & 2 deletions pymbolic/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from sys import intern
from typing import TYPE_CHECKING, ClassVar, TypeAlias

from immutabledict import immutabledict
from constantdict import constantdict

import pytools.lex
from pytools import memoize_method
Expand Down Expand Up @@ -348,7 +348,7 @@ def parse_postfix(self, pstate, min_precedence, left_exp):

if kwargs:
left_exp = primitives.CallWithKwargs(
left_exp, args, immutabledict(kwargs))
left_exp, args, constantdict(kwargs))
else:
left_exp = primitives.Call(left_exp, args)

Expand Down
9 changes: 4 additions & 5 deletions pymbolic/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)
from warnings import warn

from immutabledict import immutabledict
from constantdict import constantdict
from typing_extensions import TypeIs, dataclass_transform

from pytools import module_getattr_for_deprecations
Expand Down Expand Up @@ -621,8 +621,7 @@ def __pos__(self) -> ArithmeticExpression:

def __call__(self, *args, **kwargs) -> Call | CallWithKwargs:
if kwargs:
from immutabledict import immutabledict
return CallWithKwargs(self, args, immutabledict(kwargs))
return CallWithKwargs(self, args, constantdict(kwargs))
else:
return Call(self, args)

Expand Down Expand Up @@ -1216,10 +1215,10 @@ def __post_init__(self):
warn("CallWithKwargs created with non-hashable kw_parameters. "
"This is deprecated and will stop working in 2025. "
"If you need an immutable mapping, "
"try the :mod:`immutabledict` package.",
"try the :mod:`constantdict` package.",
DeprecationWarning, stacklevel=3
)
object.__setattr__(self, "kw_parameters", immutabledict(self.kw_parameters))
object.__setattr__(self, "kw_parameters", constantdict(self.kw_parameters))


@expr_dataclass()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
"Topic :: Utilities",
]
dependencies = [
"immutabledict",
"constantdict",
"pytools>=2024.1.16",
# for dataclass_transform, TypeAlias, deprecated
"typing-extensions>=4.5",
Expand Down

0 comments on commit a2ecb3c

Please sign in to comment.