The Incredible Growth of Python (stackoverflow.blog)

Marko Rauhamaa marko at pacujo.net
Mon Sep 11 03:58:10 EDT 2017


Gregory Ewing <greg.ewing at canterbury.ac.nz>:

> Chris Angelico wrote:
>> Async functions in
>> JS are an alternative to callback hell; most people consider async
>> functions in Python to be an alternative to synchronous functions.
>
> What do you base that on? Seems to me async is an alternative
> to callback-based frameworks such as Twisted.
>
> Calling async functions an alternative to sync functions
> doesn't make sense, because if sync functions will do what
> you want, there's no need to use async ones.

Asyncio makes it possible to write a single-threaded program in
multithreading style.

The multithreading style means entwining the state of a finite state
machine in the form of the source code. While a callback-based program
will use one or more variables (object attributes) to store the state --
or leave it implicit -- an asyncio program marks each state with the
"await" keyword.

The multithreading style is convenient in cases where each state is
blocked on a single possible event. Trouble is, most state machines I
run into (and that's my bread and butter), each state is blocked on
several or even numerous alternative events.


Marko



More information about the Python-list mailing list