improve signature of ffi::PyIter_Send & add PyIterator::send#4746
improve signature of ffi::PyIter_Send & add PyIterator::send#4746davidhewitt merged 2 commits intoPyO3:mainfrom
ffi::PyIter_Send & add PyIterator::send#4746Conversation
9cd432e to
00708ec
Compare
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks very much for this! I think this looks good to me, with just a thought on documentation.
| } | ||
|
|
||
| impl<'py> Bound<'py, PyIterator> { | ||
| /// Sends a value into the iterator. |
There was a problem hiding this comment.
I think it might be helpful to link users to more documentation about how this works, and/or write something like "equivalent to self.send(value). Similarly I guess PySendResult, while pretty clear from the names, might be worth having comments like "the generator yielded another value" or "the generator returned".
I say generator above... I guess this function only makes sense for generators? (As far as I know, send is always paired with the yield keyword in Python? I wonder, is there a way we can replicate the yield in Rust?)
There was a problem hiding this comment.
I say generator above... I guess this function only makes sense for generators? (As far as I know,
sendis always paired with theyieldkeyword in Python? I wonder, is there a way we can replicate theyieldin Rust?)
We cannot distinguish between normal python iterators and generators (because they are the same). A normal iterator just ignores the value being send.
|
Also needs both |
a2265a7 to
24e5272
Compare
24e5272 to
efc4dad
Compare
Added the missing return value of
ffi::PyIter_Sendand made a safe wrapper in PyIterator for convenience,closes #4727