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~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QM7MIHKP2GSBN6TYMPDIFKGHGC7KEH6E/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to