[Python-ideas] async/await in Python

Yury Selivanov yselivanov.ml at gmail.com
Mon Apr 20 16:02:29 CEST 2015


Lukasz,

On 2015-04-19 3:28 PM, Łukasz Langa wrote:
> On Apr 19, 2015, at 12:06 PM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
>
>> On 2015-04-19 2:52 PM, Antoine Pitrou wrote:
>>> On Sun, 19 Apr 2015 14:44:00 -0400
>>> Yury Selivanov <yselivanov.ml at gmail.com>
>>> wrote:
>>>> Queries in __getattr__
>>>> are bad because of many reasons.
>>> If you think they are bad, it means you probably don't like ORMs, since
>>> that's a primary feature of theirs.
>> I don't like that particular "feature" of most popular ORMs
>> available today.
> Our personal likes aside, one of asyncio’s design goals was to disallow implicit yield points. This is a philosophical decision going back to PEP 20 and the attribute/method distinction in Python. As opposed to, say, Ruby and its Uniform Access Principle, in Python users expect obj.thing to be instant, as opposed to obj.get_thing(), which might take a non-trivial amount of time.
>
> In asyncio this is even more important since exclusively explicit yield points enable the user to reason about concurrency and thus the correctness of the implementation. As long as you’re not yielding, you are guaranteed* the global state of your thread is not going to mutate under your feet (signals and cancellations not-withstanding).
>
> Yes, it’s true that we can’t replicate the current SQLAlchemy API in a performant way in asyncio. As far as I understand, we don’t want to. That being said, you *can* implement ORMs with explicit DB communication. FWIW, it looks like it would be easier to modify the Django ORM’s API to work with asyncio.

Exactly. This really summarizes the discussion.

Thank you,
Yury


More information about the Python-ideas mailing list