Skip to content
Opensource internals
  • Posts

Cpython

CPython's type Implementation in C (the Metaclass): How Classes Are Objects

Oct 20, 2026 10 min read Jay Hubbert

A Python class is a C struct full of function pointers — tp_dealloc, tp_getattro, tp_new — and PyType_Ready is what fills in the blanks it inherits from the base.

PythonCpythonInternalsTypeMetaclass

Read more →

CPython's types.GenericAlias Implementation in C

Oct 20, 2026 11 min read Jay Hubbert

types.GenericAlias is a five-field C struct wrapping an origin and a tuple of args, with parameters computed lazily and cached under a critical section.

PythonCpythonInternalsGenericaliasTyping

Read more →

CPython's TypeVar, TypeVarTuple, and ParamSpec Implementation in C: Typing Moves to C

Oct 20, 2026 6 min read Jay Hubbert

Typing’s core objects are now C structs with lazily-evaluated bounds and defaults — an evaluate_* callable is resolved and cached the first time you read it.

PythonCpythonInternalsTypingTypevar

Read more →

CPython's Union Type Implementation in C (X | Y): A Real Object, Not a Singleton

Oct 20, 2026 9 min read Jay Hubbert

A union owns its arguments: it dedups them with a set, flattens nested unions, normalizes None to NoneType, and collapses a one-member union back to that member.

PythonCpythonInternalsUnion

Read more →

CPython's Weak Reference Implementation in C (weakref): Pointers That Don't Own

Oct 20, 2026 11 min read Jay Hubbert

A weak reference points at an object without owning it — so reading it requires trying to incref the target under a lock, and failing means the target is gone.

PythonCpythonInternalsWeakref

Read more →

← Newer Page 9 of 11 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·