Sorry, there was a problem.
There was an error retrieving your Wish Lists. Please try again.Sorry, there was a problem.
List unavailable.
Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the author
OK
CPython Internals: Your Guide to the Python 3 Interpreter
Purchase options and add-ons
Get your guided tour through the Python 3.9 interpreter: 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 To:
- 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 Author:
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 Book:
“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
- ISBN-101781252548
- ISBN-13978-1775093343
- Publication dateMay 5, 2021
- LanguageEnglish
- Dimensions6 x 0.89 x 9 inches
- Print length394 pages
Frequently bought together

Deals on related products
Customers also bought or read
- Fluent Python: Clear, Concise, and Effective Programming
Paperback$43.99$43.99FREE delivery Wed, May 13 - Operating Systems: Three Easy Pieces#1 Best SellerComputer Operating Systems Theory
Paperback$28.27$28.27Delivery Wed, May 13 - Architecture Patterns with Python: Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices
Paperback$37.10$37.10FREE delivery Wed, May 13 - Effective Python: 125 Specific Ways to Write Better Python (Effective Software Development Series)
Paperback$52.80$52.80FREE delivery Wed, May 13 - Reinforcement Learning, second edition: An Introduction (Adaptive Computation and Machine Learning series)
Hardcover$67.26$67.26FREE delivery Wed, May 13 - Machine Learning with PyTorch and Scikit-Learn: Develop machine learning and deep learning models with Python
Paperback$37.95$37.95FREE delivery Wed, May 13 - Design Patterns: Elements of Reusable Object-Oriented Software#1 Best SellerObject-Oriented Design
Hardcover$31.92$31.92Delivery May 25 - 28 - C Programming Language, 2nd Edition#1 Best SellerC Programming Language
Paperback$56.99$56.99FREE delivery May 23 - 28 - Designing Machine Learning Systems: An Iterative Process for Production-Ready Applications
Paperback$40.00$40.00FREE delivery Wed, May 13 - Inside the Machine: An Illustrated Introduction to Microprocessors and Computer Architecture
Paperback$42.11$42.11FREE delivery Wed, May 13 - Essentials of Compilation: An Incremental Approach in Racket
Hardcover$28.49$28.49Delivery Wed, May 13 - Introduction to Algorithms, fourth edition#1 Best SellerProgramming Algorithms
Hardcover$84.99$84.99FREE delivery Thu, May 14 - The Hundred-Page Language Models Book: hands-on with PyTorch (The Hundred-Page Books)
Paperback$46.95$46.95FREE delivery Wed, May 13 - Systems Performance (Addison-Wesley Professional Computing Series)#1 Best SellerComputer Performance Optimization
Paperback$65.95$65.95FREE delivery Wed, May 13 - Deep Learning for Coders with Fastai and PyTorch: AI Applications Without a PhD
Paperback$43.99$43.99FREE delivery Wed, May 13 - Python Pocket Reference: Python In Your Pocket (Pocket Reference (O'Reilly))
Paperback$13.79$13.79Delivery May 22 - 27 - Coding Interview Patterns: Nail Your Next Coding Interview#1 Best SellerData Structure and Algorithms
Paperback$40.00$40.00FREE delivery Wed, May 13 - Mathematics of Machine Learning: Master linear algebra, calculus, and probability for machine learning
Paperback$50.99$50.99FREE delivery Wed, May 13 - Python Testing with pytest: Simple, Rapid, Effective, and Scalable
Paperback$45.95$45.95FREE delivery Wed, May 13 - 50 Algorithms Every Programmer Should Know: Tackle computer science challenges with classic to modern algorithms in machine learning, software design, data systems, and cryptography
Paperback$35.55$35.55FREE delivery Wed, May 13 - Structure and Interpretation of Computer Programs - 2nd Edition (MIT Electrical Engineering and Computer Science)
Paperback$48.08$48.08FREE delivery Wed, May 13
Product details
- ASIN : 1775093344
- Publisher : Real Python (realpython.com)
- Publication date : May 5, 2021
- Language : English
- Print length : 394 pages
- ISBN-10 : 1781252548
- ISBN-13 : 978-1775093343
- Item Weight : 1.23 pounds
- Dimensions : 6 x 0.89 x 9 inches
- Best Sellers Rank: #791,402 in Books (See Top 100 in Books)
- #423 in Python Programming
- #574 in Software Development (Books)
- #945 in Computer Programming Languages
- Customer Reviews:
About the author

Discover more of the author’s books, see similar authors, read book recommendations and more.
Products related to this item
Customer reviews
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonTop reviews from the United States
There was a problem filtering reviews. Please reload the page.
- Reviewed in the United States on May 19, 2021Format: PaperbackVerified PurchaseThis guide is a very straightforward introduction and dive into the insides of how Python's core interpreter works. It did a very good job, for me, of introducing how Python works and thinks as well as open a lot of places to explore and learn more about how and why Python works like it does. Extremely glad I got this because it unlocked a lot of understanding for me. I still need to read it a few more times to really get my head around it all, but as a tour of the pieces and why they are there and how the work together, this is a very welcome onramp.
- Reviewed in the United States on August 20, 2022Format: PaperbackVerified PurchaseLike me, if you are curious to learn in depth about Python compilation and execution methodology, this is the perfect book for you.
Having read 3 other books on Python fundamentals to advanced techniques, I can say this book provides the most Python fundamental knowledge to readers.
Only thing to keep in mind is that this is not a holistic reference book on Python, so do not expect it to cover about each data structure.
- Reviewed in the United States on September 9, 2022Format: PaperbackVerified PurchaseA deep dive into the Python Interpreter internals
- learn how to extend the language
- understand how source code is transformed into ASTs and bytecode
- deep dive into custom GIL optimizations
- some good performance tuning tips
I learned much from this book.
One possible improvement would be sequence diagrams describing the various internal code flows - easier to grok.
- Reviewed in the United States on June 17, 2023Format: PaperbackVerified PurchaseWell written, interesting, detailed coverage of how CPython works, documenting all the main internal wheels.
I gave it a 4 because of a very annoying feature of the type - some of the text (strings and comments) is a very pale gray. Reserved words and numbers are also gray although not as pale. Both are very hard to read. They may be nicely colored and highlighted in the digital version. The value of putting them in a different font/color is unclear in such simple B&W examples.
Amazingly I downloaded the Python source following the directions and it built! My experience with other open source hasn't been so orderly.
- Reviewed in the United States on May 17, 2021Format: PaperbackVerified Purchaseexcellent book to better understand python. Highly recommended!!!!
- Reviewed in the United States on August 18, 2021Format: PaperbackVerified PurchaseBook arrived in good condition. Without any damage
- Reviewed in the United States on May 17, 2021Format: PaperbackShort answer is: I was very impressed by this book because it is well written, focuses on Python 3.9, provides detailed instructions, and the code samples were tested across the three major operating systems: MacOS, Linux and Windows.
What it is not: If you are only wanting a primer on how to write a "C" extension for Python then this is not what this book is about.
What this book is: Step-by-step instructions explain how you can setup a "C" compiler (explaining MacOS, Linux and Windows setup separately), pull down the open-source "C" programs from the internet, and compile your own executable version of the enormously popular CPython interpreter. The book goes into great detail about the concepts and purposes behind what that "C" code does under the hood (lexing, parsing, etc). Anthony Shaw's book is aimed more at the very curious Python programmers who want to try out newer versions of the continually evolving CPython... perhaps to someday contribute to that effort, or maybe to insert their own custom fixes or enhancements... without having to wait for the next major release. This book is also aimed at the more serious programmers who are simply curious about what the CPython interpreter actually does internally, to gain an understanding of how Python's dictionary objects defined in the "C" source, and so on.
This book is written in a clear manner and will open up a new world for those seeking this kind of information! And just in case you're wondering: No, I don't work for the author or RealPython. I'm not being paid a dime for this recommendation.
--DT
- Reviewed in the United States on May 10, 2021Format: PaperbackThis book is the real deal, a lifetime of entertainment as you explore the bowels of Python.
Any serious python programmer should consider working through this book. It will keep you
busy. The good news is the people who wrote it know what they are talking about and they
talk to you in a nice way. That makes a lot of difference. While I am here I should make a plug
for the realpython.com site. This book along with a lot of other great learning materials are
available there. Again, nice people who will take you where you're at and help you move
forward with your python programming skills.
Top reviews from other countries
Daniel DimmickReviewed in the United Kingdom on May 13, 20215.0 out of 5 stars Writing code is one thing...
Format: PaperbackVerified Purchaseknowing the why and the how is quite another
knowing the why and the how is quite another5.0 out of 5 stars
Daniel DimmickWriting code is one thing...
Reviewed in the United Kingdom on May 13, 2021
Images in this review
Junejie RuzolReviewed in Singapore on August 23, 20215.0 out of 5 stars mishandled by amazon
Format: PaperbackVerified Purchase
5.0 out of 5 stars
Junejie Ruzolmishandled by amazon
Reviewed in Singapore on August 23, 2021
Images in this review
Tudor PlugaruReviewed in Germany on June 7, 20215.0 out of 5 stars Well written!
Format: PaperbackVerified PurchaseThis is an excellent book and one that I was looking for. For long, I was planning to looking into how to contribute to CPython, and this book finally made me start.
-
JoséReviewed in Brazil on July 27, 20245.0 out of 5 stars Muito bom
Format: PaperbackVerified PurchaseLivro em inglês bem direto, explica bem todos os detalhes e sabendo só o inglês técnico já consegue ler e compreender bem os conceitos. Recomendo que tenha um pouco de conhecimento de python e construção de compiladores, para entender os termos como LL e outros.
HjortReviewed in Sweden on March 30, 20221.0 out of 5 stars Missing index makes an else good book more or less useless
Format: PaperbackVerified PurchaseThe content of this book is great and is clearly a higher rating than one star. But a technical book without an index is considered incomplete and quite useless as a quick reference.


















![Computer Networking Bible: [3 in 1] The Complete Crash Course to Effectively Design, Implement and Manage Networks. Including Sections on Security, Performance and Scalability](/web/20210226063146if_/https://code.visualstudio.com/assets/github-https-m.media-amazon.com/images/I/41H4YJnxKgL._AC_SR100,100_QL65_.jpg)

