生成器以另一种语言运行 [英] generator functions in another language

查看:72
本文介绍了生成器以另一种语言运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很好奇是否有办法在C中编写生成器函数

(不是生成器表达式),或者最简单的方法是什么?

是...除了链接Python运行时。

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.

推荐答案

2008年5月3日星期六16:39:43 -0700, castironpi写道:
On Sat, 03 May 2008 16:39:43 -0700, castironpi wrote:

我真的很好奇,如果有办法编写生成器函数

(不是生成器表达式)在C中,或者最简单的方法是什么?
是...除了链接Python运行时。
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.



Python的参考实现是用C语言编写的,所以很明显

必须是在C语言中编写类似生成器的方法。 br />

Ciao,

Marc''BlackJack''Rintsch

The reference implementation of Python is written in C, so obviously there
must be a way to write something like generators in C.

Ciao,
Marc ''BlackJack'' Rintsch


En Sun,2008年5月4日01 :08:34-0300,Marc''BlackJack''Rintsch< bj **** @gmx.netescribió:
En Sun, 04 May 2008 01:08:34 -0300, Marc ''BlackJack'' Rintsch <bj****@gmx.netescribió:

2008年5月3日星期六16: 39:43 -0700,castironpi写道:
On Sat, 03 May 2008 16:39:43 -0700, castironpi wrote:

>我真的很好奇,如果有办法写一个发电机功能
(不是C中的生成器表达式,或者最简单的方法是什么呢?除了链接Python运行时之外。
>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.



Python的参考实现是用C语言编写的,所以显然有一些

必须是一种在C语言中编写类似生成器的方法。 b $ b


The reference implementation of Python is written in C, so obviously there
must be a way to write something like generators in C.



是和否。生成器绑定到框架,框架执行Python代码,而不是C.没有简单的方法在C中编写生成器,但是在itertools模块中有一些类似于生成器的示例。

请参阅此主题 http://groups.google.com /group/comp....2f72f2d0e88fc/

-

Gabriel Genellina

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....2f72f2d0e88fc/

--
Gabriel Genellina


2008年5月4日星期日凌晨1点39分,< ca ******** @ gmail.comwrote:
On Sun, May 4, 2008 at 1:39 AM, <ca********@gmail.comwrote:

我真的很好奇,如果有办法在C中编写生成器函数

(不是生成器表达式),或者最简单的方法是什么?

是...除了链接Python运行时。

-
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.
--



这里是itertools C代码:

http://svn.python.org/view/python/tr...34&view=markup


David。

Here''s the itertools C code:

http://svn.python.org/view/python/tr...34&view=markup

David.


这篇关于生成器以另一种语言运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆