On Mon, Aug 21, 2017 at 5:39 PM, Koos Zevenhoven <k7hoven at gmail.com> wrote: [..] >> In the current version of the PEP, generators are initialized with an >> empty LogicalContext. When they are being iterated (started or >> resumed), their LogicalContext is pushed to the EC. When the >> iteration is stopped (or paused), they pop their LC from the EC. >> > > Another quick one before I go: Do we really need to push and pop a LC on > each next() call, even if it most likely will never be touched? Yes, otherwise it will be hard to maintain the consistency of the stack. There will be an optimization: if the LC is empty, we will push NULL to the stack, thus avoiding the cost of allocating an object. I measured the overhead -- generators will become 0.5-1% slower in microbenchmarks, but only when they do pretty much nothing. If a generator contains more Python code than a bare "yield" expression, the overhead will be harder to detect. Yury
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4