Implements Comparable for PyDictKeys, PyDictItems#3366
Conversation
| ) | ||
| } | ||
| ref _set @ PySet => { | ||
| let inner = Self::to_set(zelf.to_owned(), vm)?; |
There was a problem hiding this comment.
I am not sure this line is fine or not.
If you have any idea, please comment
There was a problem hiding this comment.
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.
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_viewmacro to outside,because only
PyDictItems,PyDictKeysneed 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