Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a class for CachedMapper-derived mappers instead of a dict #549

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

majosm
Copy link
Collaborator

@majosm majosm commented Sep 24, 2024

Adds classes to represent the caches of CachedMapper-derived mappers, which will be useful for adding array duplication checks and result deduplication (#550). Both of these features add additional cache dictionaries and cache retrieval/addition logic; this change minimizes the amount of logic that must be duplicated when mappers override rec, as well as minimizes the extra arguments that need to be passed around for function caches when cloning new mappers.

Depends on #531 (merged).

@majosm majosm force-pushed the add-cache-class branch 3 times, most recently from a34936a to 378d439 Compare September 24, 2024 18:02
This was referenced Sep 24, 2024
@majosm majosm force-pushed the add-cache-class branch 3 times, most recently from 1cf2454 to df7db39 Compare December 20, 2024 22:49
@majosm majosm force-pushed the add-cache-class branch 4 times, most recently from d40153c to e9b4ac5 Compare January 13, 2025 16:09
@majosm majosm force-pushed the add-cache-class branch 2 times, most recently from c25dce2 to 7a556ad Compare January 16, 2025 22:32
Copy link
Collaborator Author

@majosm majosm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inducer This is probably good for a look too now (note that it includes the changes from #531). I pointed out a few things below that I'm still not sure about.

pytato/transform/__init__.py Outdated Show resolved Hide resolved
Comment on lines 331 to 310
# FIXME: Figure out the right way to type annotate these
| tuple[CacheExprT, tuple[Any, ...], dict[str, Any]],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should I annotate the args tuple and kwargs dict here so that it matches *args: P.args, **kwargs: P.kwargs?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytato/transform/__init__.py Outdated Show resolved Hide resolved
@majosm majosm marked this pull request as ready for review January 16, 2025 23:08
@majosm majosm requested a review from inducer January 16, 2025 23:08
@majosm majosm force-pushed the add-cache-class branch 2 times, most recently from a60b0f3 to 387bafb Compare January 21, 2025 15:43
pytato/transform/__init__.py Outdated Show resolved Hide resolved
pytato/transform/__init__.py Outdated Show resolved Hide resolved
pytato/transform/__init__.py Outdated Show resolved Hide resolved
Comment on lines 331 to 310
# FIXME: Figure out the right way to type annotate these
| tuple[CacheExprT, tuple[Any, ...], dict[str, Any]],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytato/transform/__init__.py Show resolved Hide resolved
pytato/transform/__init__.py Outdated Show resolved Hide resolved
pytato/transform/__init__.py Outdated Show resolved Hide resolved
@majosm majosm force-pushed the add-cache-class branch 2 times, most recently from 40b2a64 to 9cbe7f4 Compare January 24, 2025 22:43
@majosm majosm force-pushed the add-cache-class branch 2 times, most recently from 8546893 to 233c8e7 Compare January 27, 2025 21:04
@majosm
Copy link
Collaborator Author

majosm commented Jan 27, 2025

Probably good for another look now.

@majosm majosm requested a review from inducer January 27, 2025 21:40
Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

self,
key_inputs:
CacheExprT
| tuple[CacheExprT, tuple[Any, ...], dict[str, Any]],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the P-in-containers discussion to justify the Anys.

pytato/transform/__init__.py Show resolved Hide resolved
@majosm majosm enabled auto-merge (squash) January 28, 2025 00:24
@majosm majosm merged commit 26b2223 into inducer:main Jan 28, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants