
What Actually Happens When You Read a File
What Actually Happens When You Read a File 14 Things That Happen Before You Get Your Bytes Reading time: ~13 minutes You wrote data = open('file.txt').read() . Two function calls. That's all you did. Python is happy. Your bytes are there. The whole thing took 0.317 milliseconds and you moved on with your life. Under the hood, at least four separate processors woke up to serve you. One of them is inside your storage drive. Another is a dedicated interrupt controller. A third is the flash memory controller that lives alongside the NAND chips themselves, running its own firmware, maintaining its own data structures in its own RAM. And then there's your CPU, which you thought was doing all the work. Let's go look at what actually happened. The Comfortable Lie The mental model most of us carry is: open a file, read the bytes, done. The file is "on disk." Reading it means "getting it from disk." Maybe there's a cache involved. Simple. The truth is more interesting. Here's the actual stack: P
Continue reading on Dev.to Tutorial
Opens in a new tab



