[Python-Dev] Make class_getitem a class method (original) (raw)

Yury Selivanov yselivanov.ml at gmail.com
Fri Dec 15 11:47:12 EST 2017


Shouldn't we optimize the usability for pure-Python first, and then for C API?

Right now we have the 'new' magic method, which isn't a @classmethod. Making 'class_getitem' a @classmethod will confuse regular Python users. For example:

class Foo: def new(cls, ...): pass

  @classmethod
  def __class_getitem__(cls, item): pass

To me it makes sense that type methods that are supposed to be called on type by the Python interpreter don't need the classmethod decorator.

METH_STATIC is a public working API, and in my opinion it's totally fine if we use it. It's not even hard to use it, it's just mildly inconvenient at most.

Yury



More information about the Python-Dev mailing list