On Tue, Mar 29, 2022 at 12:49 PM Ethan Furman <[email protected]> wrote:
> On 3/29/22 09:14, Christopher Barker wrote:
>
> > [...] I tried to use __slots__ in TupleWithNames, but apparently you
> can't use __slots__ in a
> > tuple subclass ('cause tuple's already using it ??) -- but that could
> be done in a builtin.
> > then it wouldn't need a __dict__
>
> 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__`.)
>
> --
> ~Ethan~
>
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?
Unless you modify the TupleWithNames class on the fly, adding slot names as
they are needed. But then you need some kind of machinery for each instance
to know which slots are valid for that instance, and to block access to
slots that aren't part of that instance.
Again, I might just be a doof.
---
Ricky.
"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/GPDPVTWALPF63QBD4BPSAXA2VTQOTIIJ/
Code of Conduct: http://python.org/psf/codeofconduct/