[Python-Dev] Timeout for PEP 550 (original) (raw)
[Python-Dev] Timeout for PEP 550 / Execution Context discussion
Yury Selivanov yselivanov.ml at gmail.com
Sun Oct 15 21:33:16 EDT 2017
- Previous message (by thread): [Python-Dev] Scrapy Question
- Next message (by thread): [Python-Dev] Timeout for PEP 550 / Execution Context discussion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
It looks like the discussion about the execution context became extremely hard to follow. There are many opinions on how the spec for generators should look like. What seems to be "natural" behaviour/example to one, seems to be completely unreasonable to other people. Recent emails from Guido indicate that he doesn't want to implement execution contexts for generators (at least in 3.7).
In another thread Guido said this: "... Because coroutines and generators are similar under the covers, Yury demonstrated the issue with generators instead of coroutines (which are unfamiliar to many people). And then somehow we got hung up about fixing the problem in the example."
And Guido is right. My initial motivation to write PEP 550 was to solve my own pain point, have a solution for async code. 'threading.local' is completely unusable there, but complex code bases demand a working solution. I thought that because coroutines and generators are so similar under the hood, I can design a simple solution that will cover all edge cases. Turns out it is not possible to do it in one pass.
Therefore, in order to make some progress, I propose to split the problem in half:
Stage 1. A new execution context PEP to solve the problem just for async code. The PEP will target Python 3.7 and completely ignore synchronous generators and asynchronous generators. It will be based on PEP 550 v1 (no chained lookups, immutable mapping or CoW as an optimization) and borrow some good API decisions from PEP 550 v3+ (contextvars module, ContextVar class). The API (and C-API) will be designed to be future proof and ultimately allow transition to the stage 2.
Stage 2. When Python 3.7 is out, we'll see how people use execution contexts for async code and collect feedback. If we recognize that Python users want execution contexts for generators/asynchronous generators, we'll make a new PEP to add support for them in Python 3.8. That future discussion will be focused on generators specifically, and therefore I expect it to be somewhat more focused.
I will start working on the new PEP for stage 1 tomorrow. I expect to have a first version by the end of the week.
I will also publish PEP 550 v1 as a separate PEP (as v1 is a totally different PEP anyways).
Thanks, Yury
- Previous message (by thread): [Python-Dev] Scrapy Question
- Next message (by thread): [Python-Dev] Timeout for PEP 550 / Execution Context discussion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]