Jump to ratings and reviews
Rate this book

CPython Internals: Your Guide to the Python 3 Interpreter

Rate this book
Get your guided tour through the Python 3.9 Unlock the inner workings of the Python language, compile the Python interpreter from source code, and participate in the development of CPython.

Are there certain parts of Python that just seem like magic?

This book explains the concepts, ideas, and technicalities of the Python interpreter in an approachable and hands-on fashion.

Once you see how Python works at the interpreter level, you can optimize your applications and fully leverage the power of Python.

By the End of the Book You’ll Be Able

Read and navigate the CPython 3.9 interpreter source code. You’ll deeply comprehend and appreciate the inner workings of concepts like lists, dictionaries, and generators.Make changes to the Python syntax and compile your own version of CPython, from scratch. You’ll customize the Python core data types with new functionality and run CPython’s automated test suite.Master Python’s memory management capabilities and scale your Python code with parallelism and concurrency.Debug C and Python code like a true professional. Profile and benchmark the performance of your Python code and the runtime.Participate in the development of CPython and know how to contribute to future versions of the Python interpreter and standard library. How great would it feel to give back to the community as a “Python Core Developer?”With this book you’ll cover the critical concepts behind the internals of CPython and how they work with visual explanations as you go along.

Each page in the book has been carefully laid out with beautiful typography, syntax highlighting for code examples.

About the

Anthony Shaw is a CPython contributor and a PyCon speaker. He has a B.Sc. in Computer Science and over 8 years of experience working with Python. Anthony is also a Fellow of the Python Software Foundation and member of the Open-Source Apache Foundation.

What Python Developers Say About The

“It’s the book that I wish existed years ago when I started my Python journey. [...] After reading this book your skills will grow and you will be able solve even more complex problems that can improve our world.”

— Carol Willing, CPython Core Developer & Member of the CPython Steering Council

“CPython Internals is a great (and unique) resource for anybody looking to take their knowledge of Python to a deeper level.”

— Dan Bader, Author of Python Tricks

“There are a ton of books on Python which teach the language, but I haven’t really come across anything that would go about explaining the internals to those curious minded.”

— Milan Patel, Vice President at (a major investment bank)

“I can recommend CPython Internals to anyone who wants to get going with hacking on CPython.”

— Guido van Rossum, Creator of Python

389 pages, Kindle Edition

Published August 30, 2020

51 people are currently reading
210 people want to read

About the author

Anthony Shaw

1 book4 followers
Anthony Shaw is a CPython contributor and a PyCon speaker. He has a B.Sc. in Computer Science and over 8 years of experience working with Python. Anthony is also a Fellow of the Python Software Foundation and member of the Open-Source Apache Foundation.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
11 (25%)
4 stars
16 (36%)
3 stars
11 (25%)
2 stars
6 (13%)
1 star
0 (0%)
Displaying 1 - 9 of 9 reviews
17 reviews11 followers
August 19, 2021
Good enough to get you started cruising through the project code and understand the overall architecture and why things the way they are like immutability of tuple/string structures. Really liked the parallelism and concurrency chapter and the explanation of the GIL.
98 reviews
December 2, 2022
There's not much about CPython internals, and the small parts about internals are very shallow.

It's also not clear what the audience is. For example, it literally spends 4 pages explaining how a stack data structure works, which is explained in the first quarter of any Computer Science degree. But for actually interesting things, like the generational garbage collector, it only spends 2 pages.

Overall, it's inconsistent and it feels more like someone's notebook than a book. Very disappointing.

At least I learned a few things, like how code is parsed and converted to a Concrete Syntax Tree, and to an Abstract Syntax tree, and to a Control Flow Graph, and to Bytecode which determines which C functions will run.
144 reviews5 followers
July 14, 2024
This is an excellent book that covers the inner workings of the most common implementation of Python, CPython. It is definitely helpful to have an understanding of C (and especially the compiler/compiling process). This book would be a great reference for learning how to write a new programming language in C; it is also naturally helpful for people who are interested in extending or improving a Python implementation. At a minimum, understanding the internals will help you be more thoughtful about writing performant Python code.
Profile Image for Tung Son Do.
7 reviews
July 4, 2021
Give the answers of how/why questions related to Python built-in types, compiler, memory management, paralleism/ concurrency.
2 reviews
August 2, 2021
Solid overview of the entire cpython program. Also fun to learn about lower level programming and interacting with the os.
Profile Image for Carter.
597 reviews
September 3, 2021
This is of some interest to me, since I wanted to understand on some level how interpreters work for modern production level languages. Thank you.
6 reviews
June 17, 2024
A good intro but light on hands on activities and long for what it is.
Profile Image for pablo felgueres.
21 reviews
August 7, 2023
As a good intro book, it covers a lot of ground without excessive detail.

It's a solid resource to understand how python is compiled and run, the relationship between C and python looking at actual code, and with good examples to cement knowledge.

There's plenty in this book for a motivated individual to get started and let their curiosity explore topics more deeply.
Displaying 1 - 9 of 9 reviews

Can't find what you're looking for?

Get help and learn more about the design.