zlacker

[return to "Ask HN: What scientific phenomenon do you wish someone would explain better?"]
1. bunya0+lz1[view] [source] 2020-04-27 12:52:59
>>qqqqqu+(OP)
Asynchronous programming

With the addition of async to django core, I felt its time to finally learn the concept. I first took interest in async early last year when I re-read a medium post on Japronto; an async python web framework that claims to be faster than Go and Node.

Since then, I've been on the lookout for introductory posts about async but all I see is snippets from the docs with little or no modifications and a lame (or maybe I'm too dumb) attempt at explaining it.

I picked up multi threaded programming few weeks ago and I understand (correct me if I'm wrong) it does have similarities with asynchronous programming, but I just don't see where async fits in the puzzle.

◧◩
2. pixelm+eI1[view] [source] 2020-04-27 13:58:54
>>bunya0+lz1
The first couple of paragraphs of the documentation for asyncore, the module in Python's standard library that implemented the machinery for async IO all the way back in 2000, has a great description of what async programming is all about. Here it is:

https://python.readthedocs.io/en/latest/library/asyncore.htm...

'There are only two ways to have a program on a single processor do “more than one thing at a time.” Multi-threaded programming is the simplest and most popular way to do it, but there is another very different technique, that lets you have nearly all the advantages of multi-threading, without actually using multiple threads. It’s really only practical if your program is largely I/O bound. If your program is processor bound, then pre-emptive scheduled threads are probably what you really need. Network servers are rarely processor bound, however.'

'If your operating system supports the select() system call in its I/O library (and nearly all do), then you can use it to juggle multiple communication channels at once; doing other work while your I/O is taking place in the “background.” ...'

[go to top]