知识卡片
惰性生成控制内存
调用者在需要下一个元素时恢复生成器。内存用量由保留的状态、缓冲和单个数据项决定。逐项读取与写入可限制积压,但某一步若使用同步 I/O,暂停接口本身不会使它变成异步。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 5. Coroutines 生成器按需提供序列 · 查看原书依据
Generators allow us to perform actions lazily. We can act as and when needed, meaning lazy operations yield output values only when needed. This could be performing a computation, making a connection over a network, or loading data. This lazy evaluation is particularly useful when having to deal with large datasets that may be inefficient or unfeasible. Iterators like range serve a similar purpose, allowing
参考来源
- 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第05章《Chapter 5. Coroutines》,生成器按需提供序列(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch05.html#id32)
- 结论依据:原书比较迭代式逐个产生数据与一次性把大型数据装入内存。
- 原始内容:Generators allow us to perform actions lazily. We can act as and when needed, meaning lazy operations yield output values only when needed. This could be performing a computation, making a connection over a network, or loading data. This lazy evaluation is particularly useful when having to deal with large datasets that may be inefficient or unfeasible. Iterators like range serve a similar purpose, allowing