消息 [242304]
> I don't think it's necessary to have slots for __aiter__, __anext__, __aenter__ and __aexit__. Async iteration will never be as fast as regular iteration, and there is plenty overhead in it.
You seem to be assuming that the outer loop is the asyncio I/O loop. That might not be the case. It might be a thread-pool executor, it might be an in-memory task switcher, or it might just be something passing on items from a list. At least "__anext__" is worth being fast, IMHO.
Also note that one advantage of slots is that the user can cache their value to keep calling the same C function multiple times. That is not the case for a Python method, which can easily be replaced. Some iterators do that with their __next__ method, and it's perfectly valid. Having to look up the Python method on each iteration and calling through it sounds like unnecessary overhead. |
|
| 日期 |
用户 |
动作 |
参数 |
| 2015-05-01 12:19:22 | scoder | 修改 | recipients:
+ scoder, gvanrossum, vstinner, asvetlov, yselivanov |
| 2015-05-01 12:19:22 | scoder | 修改 | messageid: <1430482762.81.0.0161440712075.issue24017@psf.upfronthosting.co.za> |
| 2015-05-01 12:19:22 | scoder | 链接 | issue24017 messages |
| 2015-05-01 12:19:22 | scoder | 创建 | |
|