On Sat, Sep 28, 2019 at 5:56 PM Dino Viehland <dinoviehland@gmail.com> wrote:
Hm... But then you'd be paying for boxing/unboxing cost on each access. I'm actually okay with needing to use Cython if you're really that tight for space.
 

Right, but those would be rather ephemeral vs more potentially long lived members.  It'll certainly depend upon the usage pattern whether or not it's worth it.  And the point of using __slots__ is that you've decided you're tight on space but we don't force usage of Cython to go dict-free.

Well, I expect the implementation to be too hairy to bother.
 
But you could do that without the wacky API by just naming the slots _foo, _bar and have properties foo, bar.

You can also just mutate the type after the fact and replace the descriptor with the wrapped descriptor.  Wouldn't the prefixed solution work just as well for dataclasses in some form as well?

SOrry, I lost track of what you call "prefixed".

--
--Guido van Rossum (python.org/~guido)