frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

How async/await works in Python (2021)

https://tenthousandmeters.com/blog/python-behind-the-scenes-12-how-asyncawait-works-in-python/
61•sebg•1y ago

Comments

quentinp•1y ago
While it stays at the Python level, https://github.com/AndreLouisCaron/a-tale-of-event-loops really helped me to understand how asyncio and Trio are implemented. I had no idea how sleeps worked before reading that post.
incomingpain•1y ago
Page didnt load for me.

https://realpython.com/async-io-python/

Multiprocessing all the way!

emmelaich•1y ago
(2021)

Good article!

punnerud•1y ago
A more simplified version:

Synchronous code is like a single-lane road where cars (tasks) must travel one after another in perfect sequence. If one car stops for gas (waiting for I/O), every car behind it must stop too. While orderly and predictable, this creates massive traffic jams as tasks wait unnecessarily for others to complete before they can proceed.

Pure asynchronous code (with callbacks) is like dispatching multiple cars onto independent routes with no coordination. Cars move freely without waiting for each other, but they arrive at unpredictable times and following their progress becomes chaotic. It's efficient but creates a complex tangle of paths that becomes hard to maintain.

Async/await combines the best of both approaches with a multi-lane highway system. Cars follow clear, synchronous-looking routes (making code readable), but only wait at strategic "await" exit ramps when truly necessary. When a car needs data, it signals with "await", pulls off the highway temporarily, and other cars continue flowing past. Once its operation completes, it merges back into traffic and continues. This gives you the logical simplicity of synchronous code with the performance benefits of asynchronous execution - cars only wait at crossroads when they must, maximizing throughput while maintaining order.

The genius of async/await is that it lets developers write code that looks sequential while the runtime handles all the complex traffic management under the hood.

explodes•1y ago
Excellent write up. I appreciate the level of details here showing the history from the days of old, before async/await were even keywords.
bilsbie•1y ago
How does the GIL come into play here?
punnerud•1y ago
GIL is like a "red-cap" on the head for the CPU-core running the task, so you would not be able to run true Async without GIL. Have to hand the "red-cap" back, for the next task.

Instead of using a global lock ("red-cap"), Python objects have introduced a specialized reference counting system that distinguishes between "local" references (owned by a single thread) and "shared" references (accessed by multiple threads).

In that way enabling to remove GIL in the long run, now starting with making it optional.

1,700 Free Online Courses from Top Universities

https://www.openculture.com/freeonlinecourses
60•momentmaker•1h ago•6 comments

Steam Machine launches today

https://store.steampowered.com/news/group/45479024/view/685257114654870245
1291•theschwa•10h ago•1163 comments

Runing GLM-5.2 on local hardware

https://unsloth.ai/docs/models/glm-5.2
216•TechTechTech•5h ago•95 comments

In Praise of Memcached

https://jchri.st/blog/in-praise-of-memcached/
59•j03b•2h ago•21 comments

Polymarket's viral videos showed people winning big, but the bets were fake

https://arstechnica.com/tech-policy/2026/06/polymarkets-viral-videos-showed-people-winning-big-bu...
148•pseudolus•2h ago•60 comments

Cyberdecks, going analog, and convivial technology

https://blog.hydroponictrash.solar/cyberdecks-going-analog-and-convivial-technology/
55•akkartik•3d ago•24 comments

VibeThinker: 3B param model that beats Opus 4.5 on reasoning with novel SFT+GRPO

https://arxiv.org/abs/2606.16140
16•timhigins•1h ago•1 comments

Optocam Zero: a Pi Zero based digital camera made using off the shelf components

https://github.com/dorukkumkumoglu/optocamzero
118•iamnothere•7h ago•24 comments

My Mathematical Regression

https://blog.dahl.dev/posts/my-mathematical-regression/
225•aleda145•3d ago•81 comments

British Columbia, Time Zones, and Postgres

https://www.crunchydata.com/blog/british-columbia-and-time-zone-changes
120•sprawl_•7h ago•76 comments

Japanese symbols that speak without words

https://arun.is/blog/japan-symbols/
119•msephton•7h ago•48 comments

Is it time for a new Embedded Linux build system?

https://yoebuild.org/blog/time-for-a-new-build-system/
42•cbrake•4d ago•28 comments

Moebius: 0.2B image inpainting model with 10B-level performance

https://hustvl.github.io/Moebius/
246•DSemba•13h ago•65 comments

Windows NT for GameCube/Wii

https://github.com/Wack0/entii-for-workcubes
26•zdw•3d ago•4 comments

Canada plans 'nuclear renaissance' with up to 10 reactors built by 2040

https://www.cbc.ca/news/politics/federal-nuclear-strategy-9.7244509
346•geox•8h ago•193 comments

Show HN: Oak – Git alternative designed for agents

https://oak.space/oak/oak
155•zdgeier•11h ago•148 comments

Canyon HUD helmet for road riding

https://media-centre.canyon.com/en-INT/266866-new-canyon-heads-up-display-helmet-could-be-a-safet...
72•zh3•2d ago•85 comments

Flock-Powered Police Chiefs Stalking Women Shows Why Warrants Are Needed

https://ipvm.com/reports/police-chiefs-track
407•jhonovich•8h ago•158 comments

Kyber (YC W23) Is Hiring a Head of Engineering

https://www.ycombinator.com/companies/kyber/jobs/FGmI8mx-head-of-engineering
1•asontha•6h ago

Show HN: Pagecast – Publish Markdown/HTML Reports to Cloudflare Pages

https://github.com/Amal-David/pagecast
35•amaldavid•4d ago•8 comments

Prompt Injection as Role Confusion

https://role-confusion.github.io
162•x312•11h ago•86 comments

Job application asked for my SAT scores

https://mrmarket.lol/job-application-asked-for-my-sat-scores/
98•seltzerboys•6h ago•250 comments

ytr: YouTube Radio for Emacs

https://xenodium.com/ytr-youtube-radio-for-emacs
69•xenodium•5h ago•7 comments

Chevron signs 20-year power agreement with Microsoft for West Texas data center

https://www.chevron.com/newsroom/2026/q2/chevron-signs-20-year-power-agreement-with-microsoft-for...
128•cdrnsf•13h ago•117 comments

Help I accidentally a wigglegram

https://lmao.center/blog/wiggle-accidents/
497•gregsadetsky•3d ago•120 comments

Show HN: Got sick of ads, so I made my own logic puzzle site

https://puzzlelair.com/
151•HaxleRose•14h ago•102 comments

DisplayMate

https://www.displaymate.com/
98•skibz•10h ago•28 comments

Deno Desktop

https://docs.deno.com/runtime/desktop/
1035•GeneralMaximus•21h ago•374 comments

Finding the Best Dog Treat with Statistics

https://www.wespiser.com/posts/2026-06-19-best-dog-treat.html
90•wespiser_2018•9h ago•27 comments

Pledging another $400k to the Zig software foundation

https://mitchellh.com/writing/zig-donation-2026
747•tosh•13h ago•248 comments