[Python-Dev] Issues with PEP 526 Variable Notation at the class level (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sun Dec 10 14:47:45 EST 2017
- Previous message (by thread): [Python-Dev] Issues with PEP 526 Variable Notation at the class level
- Next message (by thread): [Python-Dev] Issues with PEP 526 Variable Notation at the class level
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
On Sun, 10 Dec 2017 19:17:25 +0000 Tin Tvrtković <tinchester at gmail.com> wrote:
Hello,
I'm one of the attrs contributors, and the person who initially wrote the slots functionality there. We've given up on returning a new class always since this can conflict with certain metaclasses (have you noticed you can't make a slots attrs class inheriting from Generic[T]?) and with PEP 487. I think with PEP 487 it's becoming especially evident class creation is not necessarily an idempotent operation.
Hmm... I understand you may be restricted by backwards compatibility here. But dataclasses don't have that issue, so we could decide we're incompatible with certain dataclasses from day 1.
I'm currently brainstorming alternative APIs for slots. The best solution would be for Python to actually offer a way to add slotness to a class after it's been defined, and Guido has expressed approval ( https://github.com/ericvsmith/dataclasses/issues/60#issuecomment-348719029).
The problem is less the API but the implementation. As Guido pointed out, this means the instance layout may now change after class definition. One possibility would be to allow changing the layout before the first instance (or even subclass) is instantiated, after which it would raise an error.
Regards
Antoine.
- Previous message (by thread): [Python-Dev] Issues with PEP 526 Variable Notation at the class level
- Next message (by thread): [Python-Dev] Issues with PEP 526 Variable Notation at the class level
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]