8000 [FX] Refactor immutable collections implementation by XuehaiPan · Pull Request #144640 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[FX] Refactor immutable collections implementation #144640

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

Closed
wants to merge 11 commits into from

Conversation

XuehaiPan
Copy link
Collaborator
@XuehaiPan XuehaiPan commented Jan 12, 2025

[ghstack-poisoned]
@XuehaiPan XuehaiPan requested a review from zou3519 as a code owner January 12, 2025 10:59
Copy link
pytorch-bot bot commented Jan 12, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/144640

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 1ab2ae5 with merge base bea7218 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Jan 12, 2025
XuehaiPan added a commit that referenced this pull request Jan 12, 2025
ghstack-source-id: a364ed3
Pull Request resolved: #144640
@XuehaiPan XuehaiPan requested a review from jansel January 12, 2025 11:05
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Jan 12, 2025
ghstack-source-id: 91c278d
Pull Request resolved: #144640
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 13, 2025
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Jan 13, 2025
ghstack-source-id: 0f1d38c
Pull Request resolved: #144640
immutable_dict.__hash__ = lambda self: hash(tuple(self.items()))
compatibility(is_backward_compatible=True)(immutable_dict)
@compatibility(is_backward_compatible=True)
class immutable_list(list[_T]):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are using Python 3.9+ now. list is now a generic type. We can get rid of typing.List[T]

XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 13, 2025
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Feb 4, 2025
ghstack-source-id: 8dc9cc9
Pull Request resolved: #144640
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Feb 5, 2025
ghstack-source-id: 0c9bcc4
Pull Request resolved: #144640
Update 8000
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Feb 5, 2025
ghstack-source-id: 33b5ec7
Pull Request resolved: #144640
Copy link
Contributor
@jansel jansel left a comment

Choose a reason for hiding this comment

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

broken tests

XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 18, 2025
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Feb 18, 2025
ghstack-source-id: db525a7
Pull Request resolved: #144640
XuehaiPan added a commit that referenced this pull request Feb 18, 2025
ghstack-source-id: 32a9043
Pull Request resolved: #144640
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Feb 19, 2025
ghstack-source-id: dd9b805
Pull Request resolved: #144640
@XuehaiPan XuehaiPan requested a review from jansel February 20, 2025 11:02
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 23, 2025
[ghstack-poisoned]
@XuehaiPan XuehaiPan requested a review from jansel February 23, 2025 05:13
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 23, 2025
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 23, 2025
pop = _no_mutation
popitem = _no_mutation
setdefault = _no_mutation
update = _no_mutation # type: ignore[assignment]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does only update complain?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MutableMapping.update is an overloaded method:

@overload
def update(self, /, mapping: Mapping[KT, VT]) -> None:
@overload
def update(self, /, seq2: Iterable[tuple[KT, VT]]) -> None:
@overload
def update(self, /, **kwargs: VT) -> None:

[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 23, 2025
Skylion007
Skylion007 previously approved these changes Feb 23, 2025
setdefault = _no_mutation
update = _no_mutation # type: ignore[assignment]

def __hash__(self) -> int: # type: ignore[override]
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it complaining because the superclass has the hash function blocked or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

superclass has the hash function blocked

It complains about this.

@Skylion007 Skylion007 dismissed their stale review February 23, 2025 16:46

Accidental, meant to comment

@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #147691

pytorchmergebot pushed a commit that referenced this pull request Feb 24, 2025
aditew01 pushed a commit that referenced this pull request Feb 28, 2025
Get rid of dynamic class creation via `type(name, bases, ...)`. Convert it to classic static class definition for better readability and static analysis support.

Pull Request resolved: #144640
Approved by: https://github.com/jansel
ghstack dependencies: #147699
aditew01 pushed a commit that referenced this pull request Feb 28, 2025
@github-actions github-actions bot deleted the gh/XuehaiPan/234/head branch March 27, 2025 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0