generator functions in another language

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun May 4 01:21:59 EDT 2008


En Sun, 04 May 2008 01:08:34 -0300, Marc 'BlackJack' Rintsch <bj_666 at gmx.net> escribió:

> On Sat, 03 May 2008 16:39:43 -0700, castironpi wrote:
>
>> I'm actually curious if there's a way to write a generator function
>> (not a generator expression) in C, or what the simplest way to do it
>> is... besides link the Python run-time.
>
> The reference implementation of Python is written in C, so obviously there
> must be a way to write something like generators in C.

Yes and no. Generators are tied to frames, and frames execute Python code, not C. There is no simple way to write generators in C, but there are some generator-like examples in the itertools module.
See this thread http://groups.google.com/group/comp.lang.python/browse_thread/thread/5f42f72f2d0e88fc/

-- 
Gabriel Genellina




More information about the Python-list mailing list