Are there any plans to add support for creating iterable python
The iterator protocol was described in PEP 234:
And here is the best explanation I've found of how to use the C API to
create an iterable object:
In terms of PyCXX, this seems like it would basically consist of:
(1) Adding a StopIteration exception class.
(2) Supporting tp_iter and tp_iternext slots via PythonType and
(3) Providing some way for an extension method to signal to the
"iternext_handler" that iteration is over. The function in the tp_iternext
slot can either raise a StopIteration exception, or just return NULL to
signal an end to iteration. Since the latter is faster, it would be a good
idea to somehow allow the extension method to do the same.
(Perhaps by creating an Object with a NULL pointer value, which
currently is disallowed.)
Is this something that might be forthcoming in PyCXX? If not, I'll just
hack it into my own code, but otherwise maybe I can help here.