CPython Internals: Your Guide to the Python 3 Interpreter
- Length: 389 pages
- Edition: 1
- Language: English
- Publisher: Real Python (realpython.com)
- Publication Date: 2020-01-25
- ISBN-13: 9781775093350
- Sales Rank: #0 (See Top 100 Books)
The CPython interpreter abstracts away the complexities of the underlying C platform and your operating system.
It makes threading cross-platform and straightforward.
It takes the pain of memory management in C and makes it simple.
In short, CPython gives you the platform to write scalable and performant applications using the comfortable and powerful syntax of Python…
All of the material is completely up to date for Python 3.9, the latest version of the Python programming language.
In a nutshell, here’s what you’ll learn with CPython Internals: Your Guide to the Python Interpreter:
Chapter 1: Introduction How to make the most of this book so you can learn effectively and quickly get up to speed with CPython development.
Chapter 2: Getting the CPython Source Code The CPython source distribution comes with a whole range of tools, libraries, and components. You’ll start exploring them in this chapter.
Chapter 3: Setting Up Your Development Environment Throughout this book, you’ll be working with C and Python code. In this chapter you’ll see how to configure your development environment to support both languages.
Chapter 4: Compiling CPython Now that you have CPython downloaded, set up a development environment and configured it, you can compile the CPython source code into an executable interpreter.
Chapter 5: The Python Language and Grammar Understand why CPython is written in C and not Python and then dig into the Python Language Specification and it’s Parser Generator setup.
Chapter 6: Configuration and Input Now that you’ve seen the Python grammar, its time to explore how code gets input into a state that can be executed.
Chapter 7: Lexing and Parsing With Syntax Trees In the previous chapter, you explored how Python text is read from various sources. It needs to be converted into a structure that the compiler can use. This stage is “parsing.” In this chapter, you will explore how the text is parsed into logical structures that can be compiled.
Chapter 8: The Python Compiler In this chapter, you will focus on the compilation of an AST module into a code object that the CPython interpreter can execute. These code objects contain lists of discrete operations in the form of bytecode.
Chapter 9: The Evaluation Loop Execution of code in CPython happens within a central loop, called the “evaluation loop.” In this chapter you’ll get familiar with the evaluation loop as the “brain” of CPython.
Chapter 10: Memory Management By the end of this chapter, you will understand how CPython allocates memory on the Operating System, how object memory is allocated and freed, and how CPython manages memory leaks.
Chapter 11: Parallelism and Concurrency CPython offers many approaches to Parallelism and Concurrency. Your choice depends on several factors. There are also overlapping use cases across models as CPython has evolved. This major chapter of the book will make you familiar with the relevant concepts.
Chapter 12: Objects and Types Learn how common built-in types like strings, lists, tuples, and dictionaries are implemented in CPython. You’ll also implement a custom built-in operator on Python strings in this chapter.
Chapter 13: The Python Standard Library There are two types of modules in the CPython standard library: those written in pure Python that provide a utility, and those written in C with Python wrappers. You will explore both types in this chapter.
Chapter 14: The CPython Test Suite Learn how to run CPython’s extensive test suite covering the core interpreter, the standard library, the tooling, and distribution on Windows, Linux, and macOS. If you want to get involved in the CPython project, writing or extending unit tests is a great place to start.
Chapter 15: Debugging In this chapter, you will learn how to attach a debugger to the CPython interpreter and how to use the debugger to see inside a running CPython process.
Chapter 16: Benchmarking, Profiling, and Tracing In this chapter, you have explored benchmarking, profiling, and tracing using a number of tools designed for CPython. With the right tooling, you can find bottlenecks, compare performance of multiple builds and identify improvements.
Chapter 17: Conclusion & Further Reading How you can use your newfound knowledge to extend the functionality of Python and to contribute to the CPython project.
Appendix: Introduction to C for Python Programmers This introduction is intended to get an experienced Python programmer up to speed with the basics of the C language and how it’s used in the CPython source code.
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.