[Python-ideas] yield from __setitem__ and __setattr__

Nick Coghlan ncoghlan at gmail.com
Wed Sep 10 15:43:25 CEST 2014


On 10 Sep 2014 19:41, "Martin Teichmann" <lkb.teichmann at gmail.com> wrote:
>
> Hi Guido, Hi List
>
> > I think it's too soon to start inventing new syntax to address these;
instead, I strongly
> > recommend changing your APIs to use explicit method calls instead of
the special
> > syntax you so favor. Even __getitem__() returning a Future feels
awkward to me
> > (unless it's clear that the container you have in front of you is a
container full of Futures).
> > [...]
> >  But again I would like to establish asyncio as the de-factor standard
for asynchronous work
> > before trying to tweak the language more
>
> I agree that first we need to settle a bit and look how everything
> works, but hey, this is python-ideas, the list for "discussing speculative
>  language ideas".
>
> Limiting all APIs to just use explicit method calls unfortunately
> leads to a very Java-like language that misses all the cool features
> of python. And this is not limited only to low-level stuff, but also
> high level interfaces. Right now I am actually working on a
> distributed framework, where users which are not professional
> programmers are supposed to write their own plugins. My boss
> is constantly bugging me "all that yield from stuff looks complicated,
> can't you just  put it in a function the user calls so they
> don't see it anymore?" Well, as you know, I cannot. Even in the
> highest level of abstraction, every function that needs to do I/O
> has to be yielded from.

The local visibility of the asynchronous flow control is deliberate. Folks
that don't want that behaviour to be visible in user level code have the
option of using gevent as a synchronous to asynchronous adapter to provide
a developer experience that is closer to the pre-emptive multithreading
many folks are used to working with.

For a couple of longer discussions of some of the trade-offs involved in
adopting that more implicit approach, you may want to take a look at my
post at
http://python-notes.curiousefficiency.org/en/latest/pep_ideas/async_programming.html
as well as Glyph's at
https://glyph.twistedmatrix.com/2014/02/unyielding.html

Regards,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140910/58c058e3/attachment.html>


More information about the Python-ideas mailing list