On Tue, Aug 22, 2017 at 12:44 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote: > 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. > > But if LCs are immutable, there needs to be only one empty-LC instance. That would avoid special-casing NULL in code. -- Koos > 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. -- + Koos Zevenhoven + http://twitter.com/k7hoven + -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170822/90abc557/attachment.html>
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