r/PythonLearning 2d ago

Python Under the Hood Update: Chapter 3 (Conditional Statements & Control Flow) is now complete

Hey everyone,

Chapter 3 is finally done. This chapter took way more time than I originally expected because it grew into a much deeper and larger chapter than planned.

Current Progress:
✅ Chapter 1 - Variables & Memory
✅ Chapter 2 - Expressions & Operators
✅ Chapter 3 - Conditional Statements & Control Flow

I'd love to hear your thoughts on the new chapter and any suggestions for future improvements.

With this, I’m taking a break from Python Under the Hood. I’ll be stepping away from the project for a while and will return to it before July 2027.

When I come back, we’ll continue with even deeper explanations, more advanced topics, and an even better approach to understanding what happens under the hood of Python.

For now, Chapter 3 marks the end of this phase. 🐍⚙️

GitHub: python-under-the-hood

See you in the next chapter.

- David Vael

10 Upvotes

2 comments sorted by

2

u/Sea-Ad7805 2d ago edited 2d ago

Nice, I'm missing something about shallow and deep copy in Chapter 1. I like to explain these concepts graphically: https://github.com/bterwijn/memory_graph#copying-values-of-mutable-type

In case you want to use graphics too, you probably want to unsimplify the graph in places to show what is really under the hood: https://github.com/bterwijn/memory_graph#simplified-graph

If you change an immutable value, you get a shallow copy:

a = ([1], [2])
b = a
b += ([3], )
b[0].append(11)
print(a)  # ([1, 11], [2])

This kind of fun%0Ab%20%3D%20a%0Ab%20%2B%3D%20(%5B3%5D%2C%20)%0Ab%5B0%5D.append(11)%0Aprint(a)%20%20%23%20(%5B1%2C%2011%5D%2C%20%5B2%5D)%0A&play).

2

u/DramaticParsnipq 2d ago

Chapter 3 on control flow finally clicked for me. Take the break, this is incredible work