Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I've asked merely to clarify whether your issue is with Python's asyncio (e.g. Python got it wrong) or with the tradeoffs inherent in async io APIs in general (regardless of Python)

Both, but the latter part is contextual.

> I, for one, am fine with async APIs in JS

Correct me if you think I'm wrong, but JS in its native environment (the browser) never had access to the OS thread and process scheduler, so the concept of what could be done was limited from the start. If all you're allowed to have is a hammer, it's possible to make a fine hammer.

But

1. Python has never had that constraint

2. Python's asyncio in particular is a shitty hammer that only works on special asyncio-branded nails

and 3. Python already had a better futures interface for what asyncio provides and more before asyncio was added.

The combination of all three of those is just kinda galling in a way that it isn't for JS because the contextual landscape is different.



>1. Python has never had that constraint

Which is neither here, nor there. Python had another big constraint, the GIL. So threads there couldn't go so far as async would. But even environments with threads (C#, Rust) also got big into async in the same style.

>2. Python's asyncio in particular is a shitty hammer that only works on special asyncio-branded nails

Well, that's also the case with C#, JS, and others with similar async style (aka "colored functions"). And that's not exactly a problem, as much as a design constraint.


What has GIL to do with the thread model vs asyncio? asyncio is also single threaded, so cooperative (and even preemptive) green threads would have been a fully backward compatible option.

JS never had an option as, as far as I understand, callback based async was already the norm, so async functions were an improvement over what came before. C# wants to be an high performance language, so using async to avoid allocating a full call stack per task is understandable. In python the bottleneck would be elsewhere, so scaling would be in no way limited by the amount of stack space you can allocate, so adding async is really hard to justify.


>What has GIL to do with the thread model vs asyncio?

Obviously the fact that the GIL prevents effient use of threads, so asyncio becomes the way to get more load from a single CPU by taking advantage of the otherwise blocking time.


How would the GIL prevent the use of "green" threads? Don't confuse the programming model with the implementation. For example, as far as I understand, gevent threads are not affected by the GIL when running on the same OS thread.


Try C# as a basis for comparison, then. It also has access to native threads and processes, but it adopted async - indeed, it's where both Python and JS got their async/await syntax from.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: