Add IntoIterator for &Bound types#3923
Conversation
Icxolu
left a comment
There was a problem hiding this comment.
This looks useful to me, maybe it would make sense to also do this for the other iterables (PyTuple, Py(Frozen)Set and PyDict come to mind)?
|
Thanks, I think these do make sense, I since remembered that I hit this a fair bit in Some history on why these didn't yet exist is in #3695 (comment) and #3694 (comment) - basically I think @adamreichold and I had held back on adding these previously because I'd forgotten the use case at the time :) I think the only question I have left remaining is what to do about |
There was a problem hiding this comment.
I think let's merge this as-is. I think the only possible design question is whether we would want to have extra iterator types that contain &Bound instead of Bound.
The only advantage of the extra types would be to be able to avoid one reference count operation, and iteration necessarily is N reference counting ops anyway. Due to this I think it's not worth bothering with the extra complexity of additional types.
This allows using common types like
&Bound<'py, PyList>in aforloop without explicitly callingiter().