CodeNebula
All paths

Advanced Python

Dive deep — metaclasses, descriptors, ABCs, protocols, and CPython internals.

0 / 11 completed0%
1

Metaclasses

A metaclass is the class of a class — it controls how classes are created. `type...

Python
2

Descriptors

A descriptor is an object that defines `__get__`, `__set__`, or `__delete__`. Wh...

Python
3

Abstract Base Classes (ABCs)

`abc.ABC` (or `metaclass=abc.ABCMeta`) lets you define interfaces that subclasse...

Python
4

Protocols (PEP 544) — Structural Subtyping

`typing.Protocol` (Python 3.8+) defines structural interfaces — any class that i...

Python
5

`__slots__` — Memory Optimization

By default, Python stores instance attributes in a `__dict__` per instance — fle...

Python
6

Memory Management and the `gc` Module

CPython uses reference counting as its primary GC mechanism — an object is freed...

Python
7

CPython Internals — Bytecode and `dis`

CPython compiles Python source to bytecode (`.pyc` files), which the CPython vir...

Python
8

The Import System

`import` triggers a multi-step process: find the module (using `sys.meta_path` f...

Python
9

Type Narrowing and `TypeGuard`

Type narrowing is the process by which a type checker infers a more specific typ...

Python
10

Performance Profiling

`cProfile` is CPython's built-in deterministic profiler — it records every funct...

Python
11

Escape from the GIL — Subinterpreters and Free-Threading (Python 3.12+)

Python 3.12 introduced per-interpreter GILs (PEP 684): each subinterpreter has i...

Python