Playback speed
Share post
Share post at current time

Decoding PyObject and PyTypeObject in CPython

The foundation pieces of the CPython object system

Welcome back! This is the 3rd video in the CPython Type System Internals series. In this video we finally start looking at the CPython source code and understand how the type system interface is implemented.

This video focuses on explaining the structs PyObject and PyTypeObject, which are the building blocks for the whole CPython type system. The PyObject struct plays the role of the base class which is inherited by the definition of every type. And the PyTypeObject struct contains all the type related information about an object which allows the runtime perform various operations on that object.

Next Video

In the final video of this series, we look at how an actual built-in type is implemented in CPython:

Links to All the Videos of this Series

  1. Design of the CPython Type System

  2. Emulating Inheritance and Polymorphism in C

  3. Decoding PyObject and PyTypeObject in CPython (you are here)

  4. Implementation of the Float Built-in Type in CPython (next)

Writing such in-depth articles on hard technical topics requires several days of research and writing. My goal is to build a community of 100 dedicated subscribers who value this work and want to ensure it continues. If you enjoy my content and would like to be part of this growing community, consider becoming a paid subscriber or buying me a coffee. Every subscription takes us one step closer to our goal and keeps this work sustainable.


Confessions of a Code Addict
Confessions of a Code Addict Podcast
Deep dives into varied topics on Computer Science including compilers, programming languages, database internals, AI and more. Subscribe for insights and advance your engineering skills!