from dataclasses import dataclass
 
@dataclass(slots=True)
class Point:
    x: int
    y: int

this instructs python to create class with fixed attributes instead of __dict__

This change results in:

  • Less memory usage
  • Faster accesses
  • Assignment only works for declared variables
  • Cannot add new attributes dynamically