29 Mar
2022
29 Mar
'22
12:26 p.m.
On 3/29/22 09:57, Ricky Teachey wrote:
On Tue, Mar 29, 2022 at 12:49 PM Ethan Furman wrote:
The `__dict__` is needed to store the field names -- did you add `__dict__` to the `__slots__`? (Of course, if you've added `__dict__` then you lose the limited size of `__slots__`.)
Maybe I'm being an ignoramus but: how would it be possible to even use slots? Slots are descriptors living in the class namespace. You don't know ahead of time what the member names are, so you can't use slots, right?
You can use them, just make sure one of the slots is `__dict__`. Of course, by adding `__dict__` you lose most (all?) of the advantages of using `__slots__` in the first place. -- ~Ethan~