I love this idea. It makes `__slots__` easy and efficient to define! The
current, explicit syntax is very tedious and verbose.
`__slots__ = ...` is a very clear syntax for saying "Include ALL annotated
class-variables automatically".
It would relegate manual `__slots__ = { "a", "b" }` usage to wh
> But it would silently do nothing if there was no class decorator to look
> at it.
>
This doesn't seem like such a big deal to me. It would simply be the way
slots works.
However if we did `__slots__ = "__auto__"` then we might finagle it so that
> the initializers could be preserved:
>
> class
On Sat, Sep 28, 2019 at 2:26 PM Ricky Teachey wrote:
>
> But it would silently do nothing if there was no class decorator to look
>> at it.
>>
>
> This doesn't seem like such a big deal to me. It would simply be the way
> slots works.
>
I was thinking it's currently an error. And you chose a nam
>
> On Fri, Sep 27, 2019 at 11:18 AM Serhiy Storchaka
> wrote:
>
> I think it needs an explicit support in the type creation machinery (as
>
>
> __slots__ itself has) to support descriptors and slots with the same name.
>
>
>
> That would be tough, since __slots__ is currently implemented by creat
On Sat, Sep 28, 2019 at 5:04 PM Dino Viehland
wrote:
> One thought I've had about __slots__ would be it'd be nice to take a
> dictionary in the form of:
>
> class C:
> __slots__ = {'a': ???, 'b': ???}
>
> You could actually provide this dictionary today, but the values would be
> ignored. Th
>
> 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
It looks like Serhiy answered your main question, but I wanted to mention
that rather than simply printing the exception, you could also print the
full traceback using the "traceback" module:
>>> import traceback
>>> try:
... 1/0
... except Exception as e:
... traceback.print_exc()
...
Tra
> I was thinking it's currently an error. And you chose a name
> (__slot_conflics__) suggesting that there still was a problem. But yeah,
> maybe other than that it's no big deal.
>
It's a good point; the name does seem to say "here's a problem that needs
to be solved".
Your comment makes me thin
On Sat, Sep 28, 2019 at 5:56 PM Dino Viehland
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 li