Generators in C code
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue May 15 01:57:35 EDT 2007
En Tue, 15 May 2007 02:12:40 -0300, Raymond Hettinger <python at rcn.com>
escribió:
>> I feel I'm out of luck, but if someone could point some way to write a
>> generator in C, I'be very grateful!
>
> Perhaps the code in the itertools module will provide a good example
> -- they behave like generators in many respects except that you are
> responsible for tracking state and jumping to an appropriate resume
> point. Being C, it won't be as convenient as Python generators, but
> should be able to translate any generator into equivalent C.
Oh, thanks for pointing that! (I didn't know the itertools module was
written in C - I supposed it was a Python module).
After a brief reading, I think I'll use something similar to how tee and
teedataobject store current state.
--
Gabriel Genellina
More information about the Python-list
mailing list