-
Notifications
You must be signed in to change notification settings - Fork 24.7k
[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
Conversation
🔗 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 FailuresAs of commit 1ab2ae5 with merge base bea7218 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ghstack-source-id: 91c278d Pull Request resolved: pytorch#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]): |
There was a problem hiding this comment.
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]
。
ghstack-source-id: 0f1d38c Pull Request resolved: pytorch#144640
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broken tests
ghstack-source-id: 33b5ec7 Pull Request resolved: pytorch#144640
ghstack-source-id: dd9b805 Pull Request resolved: pytorch#144640
ghstack-source-id: fc2ff52 Pull Request resolved: pytorch#144640
ghstack-source-id: fc2ff52 Pull Request resolved: pytorch#144640
pop = _no_mutation | ||
popitem = _no_mutation | ||
setdefault = _no_mutation | ||
update = _no_mutation # type: ignore[assignment] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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-source-id: df3daaf Pull Request resolved: pytorch#144640
setdefault = _no_mutation | ||
update = _no_mutation # type: ignore[assignment] | ||
|
||
def __hash__(self) -> int: # type: ignore[override] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Starting merge as part of PR stack under #147691 |
Pull Request resolved: #147691 Approved by: https://github.com/Skylion007, https://github.com/jansel ghstack dependencies: #147699, #144640
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
Pull Request resolved: #147691 Approved by: https://github.com/Skylion007, https://github.com/jansel ghstack dependencies: #147699, #144640
Stack from ghstack (oldest at bottom):
map_aggregate(immutable_dict)
#147691tree_map_only
#147699Get rid of dynamic class creation 8000 via
type(name, bases, ...)
. Convert it to classic static class definition for better readability and static analysis support.cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv @voznesenskym @penguinwu @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov