On 05/01, Guido van Rossum wrote: > On Fri, May 1, 2015 at 11:26 AM, Jim J. Jewett <jimjjewett at gmail.com> wrote: >> So does this mean that yield should NOT be used just to yield control >> if a task isn't blocked? (e.g., if its next step is likely to be >> long, or low priority.) Or even that it wouldn't be considered a >> co-routine in the python sense? >> > > I'm not sure what you're talking about. Does "next step" refer to something > in the current stack frame or something that you're calling? None of the > current uses of "yield" (the keyword) in Python are good for lowering > priority of something. It's not just the GIL, it's that coroutines (by > whatever name) are still single-threaded. If you have something > long-running CPU-intensive you should probably run it in a background > thread (or process) e.g. using an executor. So when a generator is used as an iterator, yield and yield from are used to produce the actual working values... But when a generator is used as a coroutine, yield (and yield from?) are used to provide context about when they should be run again? -- ~Ethan~
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