Skip to content

Commit

Permalink
add questions/comments
Browse files Browse the repository at this point in the history
  • Loading branch information
majosm committed Dec 20, 2024
1 parent 9154366 commit a325da2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pytato/stringifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def __init__(self,
# Uses the same cache for both arrays and functions
self._cache: dict[tuple[int, int], str] = {}

# Should expr be ArrayOrNames instead of Any?
def rec(self, expr: Any, depth: int) -> str:
# Why cache by ID?
cache_key = (id(expr), depth)
try:
return self._cache[cache_key]
Expand Down
3 changes: 3 additions & 0 deletions pytato/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ class TransformMapper(CachedMapper[ArrayOrNames, FunctionDefinition, []]):
implement default mapper methods; for that, see :class:`CopyMapper`.
"""
# FIXME: This inflates recursion depth
def rec_ary(self, expr: Array) -> Array:
res = self.rec(expr)
assert isinstance(res, Array)
Expand All @@ -335,6 +336,7 @@ def rec_ary(self, expr: Array) -> Array:
# {{{ TransformMapperWithExtraArgs

class TransformMapperWithExtraArgs(
# Why multiple inheriting?
CachedMapper[ArrayOrNames, FunctionDefinition, P],
Mapper[ArrayOrNames, FunctionDefinition, P]
):
Expand All @@ -345,6 +347,7 @@ class TransformMapperWithExtraArgs(
The logic in :class:`TransformMapper` purposely does not take the extra
arguments to keep the cost of its each call frame low.
"""
# FIXME: This inflates recursion depth
def rec_ary(self, expr: Array, *args: P.args, **kwargs: P.kwargs) -> Array:
res = self.rec(expr, *args, **kwargs)
assert isinstance(res, Array)
Expand Down

0 comments on commit a325da2

Please sign in to comment.