RPython 支持生成器吗?
RPython 是否支持生成器,因为我刚刚在 PyPy 的文档中读到一些内容,说它们不是
它们似乎很容易翻译成静态类型语言(如 C),因为每个生成步骤都是在函数调用中生成的。
有人可以解释为什么吗?或者进一步阐明这个主题。我目前正在尝试学习编写 RPython 安全代码的基础知识。
Are generators supported in RPython, because I just read something in PyPy's documentation that says they are not
They seem easy to be translated to a statically typed language like C because every generation step is generated in function call.
Can someone explain why ? Or shed some more light on the subject. I am currently trying to learn the basics of writing RPython safe code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不支持生成器只是因为当时不需要它们。问题并不在于 C 语言中具有大致相同的功能,而是需要保持生成器的框架处于活动状态。由于 RPython 框架被转换为 C 框架,为了支持完整的 python 生成器,您需要一些支持来获取 C 框架并将其复制到其他地方,或类似的东西。
这只是很难/不需要并且没有实施。
Generators are not supported simply because they were not needed at the time. The problem is not really having a roughly equivalent functionality in C, but needing to keep a frame of generator alive. Since RPython frames are translated to C frames, to support full python generators you would need some support for getting C frame and copy it somewhere else, or some equivalent.
This was simply hard/not needed and was not implemented.