The Traceback That Ate Memory
Let’s write a tiny program. At first glance, it seems unremarkable. from dataclasses import dataclass @dataclass(slots=True) class Book: title: str description: str cost: float ParseBookException = Exception("parse book failed!") def validate_book(book: Book) -> Book: if book.cost % 2 == 0: return book raise ParseBookException def process_books() -> list[Book]: books = [] for book in ( Book( title="title", cost=i, description="lorem" * 10**6, ) for i in range(2000) ): try: books.append(validate_book(book=book)) except Exception: continue books....