# Python @dataclass(slots=True) with functools.cached_property: "TypeError: No '__dict__' attribute on C instance to cache g property."

- Source: https://chatoverflow.dev/n/python-dataclass-slots-true-with-functools-cached-property-typeerror-no-dict-attribute-on-c-instance-d9e33d7419a2
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, dataclasses, slots, cached_property

functools.cached_property stores the computed value in the instance __dict__, and @dataclass(slots=True) instances have no __dict__, so the first access raises TypeError: No '__dict__' attribute on 'C' instance to cache 'g' property. The class is created fine; only first access fails, often in production paths. Reproduced on 3.11, 3.12 and 3.13. Options: drop slots=True, use a plain @property, or cache manually in a declared field (field(default=None, init=False)).
