This week I read real code written by Python’s own developers: bisect.py, Python’s binary search.
Before opening it, I wrote my plan for reading a codebase:

At the bottom there are nicknames: bisect is bisect_right and insort is insort_right. Python also tries to swap in a faster version written in C. If it’s missing, it uses these.

On the list [1, 3, 3, 5]:
bisect_left with 3: I said box 1. Correct!bisect_right with 3: I said box 3. Correct!bisect_left with 4: I said box 1, but it was 3. I thought about where a three fits, not a four. A 4 goes between 3 and 5.bisect_left puts the new 3 before the other 3s. bisect_right puts it after them.
An empty list gives 0, and I predicted that right.
Why is half the code comments?
I wrote all the steps on paper from memory, then built Hello World and Hello Cargo again. I fixed three errors myself: two folders already existed, and I used print instead of println!.
Then I removed a quotation mark on purpose. Rust said “unterminated double quote string”. That means the string started but never ended, so we need to add the quote at the end.
Cargo is for building and running.
First I wrote how I’d play a number guessing game with Agastya:
Then I typed the whole game from Chapter 2. My error was using a semicolon instead of a comma. I guessed 4, 8, then 10, and it said “You win!”
