Playback speed
undefinedx
Share post
Share post at current time
0:00
/
0:00

Emulating Inheritance and Polymorphism in C

Using struct embedding and function pointers to emulate inheritance and polymorphism in C

This is the 3rd video on the series on the CPython Type System Internals series. In this video we discuss how can we emulate the behaviors of inheritance and polymorphism in C using a couple of simple tricks with structs.

This is important to understand before we start looking at the CPython type system implementation because it builds on top of these tricks.


Next Video

In the next video, we will explore the CPython source code, and we will start by understanding how it defines the type system interface which is used by the rest of the runtime.

Links to All the Videos of this Series

  1. Design of the CPython Type System

  2. Emulating Inheritance and Polymorphism in C (you are here)

  3. Decoding PyObject and PyTypeObject in CPython (next)

  4. Implementation of the Float Built-in Type in CPython


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.

Share

0 Comments
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!