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__`.)
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.
"I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler