Class Design for Compilation
May 30, 2026 | 5 min read
Simple Classes Compile Best
@dataclass
class Point:
x: float
y: floatAvoid Complex Metaclasses
Custom metaclasses other than ABCMeta may fall back to CPython.
Prefer Slots for Memory
class Item:
__slots__ = ['name', 'price']Method Call Overhead
Method calls are slightly slower than free functions. For hot inner loops, consider extracting to a free function.