-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implements Comparable for PyDictKeys, PyDictItems #3366
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
) | ||
} | ||
ref _set @ PySet => { | ||
let inner = Self::to_set(zelf.to_owned(), vm)?; |
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.
I am not sure this line is fine or not.
If you have any idea, please comment
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.
to_set
make copy of all elements. Iterating all elements in zelf and using PySet::contains
may make sense like all_contained_in
in cpython. Although we dont have PySequence_Contains
, we have PySet
type we can use it 😊
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.
Okay. I'll check and fix it. 👍 😄
there are |
How about putting cmp to ViewSetOps to reuse it from items and keys? |
@youknowone |
I think you can move the whole |
For #3298
I moved Comparable Implements in
dict_view
macro to outside,because only
PyDictItems
,PyDictKeys
need to implement Comparable, notPyDictItems
.(check in https://github.com/python/cpython/blob/9942f42a93ccda047fd3558c47b822e99afe10c0/Objects/dictobject.c#L4703, https://github.com/python/cpython/blob/9942f42a93ccda047fd3558c47b822e99afe10c0/Objects/dictobject.c#L4809)
After #3316(PySequence Layer) is merged, Comparable implementation can be simpler.
But now, I just let it compare differently depending on the type.
before
after