This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Mechanism to enable __weakref__ slot on dataclass(slots=True)
Type: Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ariebovenberg, eric.smith
Priority: normal Keywords:

Created on 2022-03-18 18:00 by ariebovenberg, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg415515 - (view) Author: Arie Bovenberg (ariebovenberg) * Date: 2022-03-18 18:00
As discussed in bpo-46382, dataclasses may want to support the __weakref__ slot.

Currently, automatically slotted dataclasses are not given a __weakref__ slot. This makes auto-slotted dataclasses incompatible with weakref.

The attrs library has chosen for the following approeach:
- when slots are generated, a __weakref__ slot is added by default
- this may be optionally disabled with the weakref_slot=False flag

See this discussion on why that approach was taken: https://github.com/python-attrs/attrs/pull/420

The question for dataclass is: do we want to follow suit? Or perhaps make __weakref__ slot opt-in instead of opt-out?
History
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91215
2022-03-18 18:00:50ariebovenbergcreate