<div dir="ltr"><div>I like this idea. I have few suggestions for the test cases you added, will add them a bit later in the PR.<br><br>--<br></div>Ivan<br><br><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 15 December 2017 at 16:00, Serhiy Storchaka <span dir="ltr"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The class itself always is passed as the first argument to __class_getitem__():<br>
<br>
  cls.__class_getitem__(cls, item)<br>
<br>
I propose to make __class_getitem__ a class method. This will make simpler implementing it in C. Currently it should be declared with flags METH_VARARGS|METH_STATIC and implementing as<br>
<br>
static PyObject *<br>
generic_class_getitem(PyObject *Py_UNUSED(self), PyObject *args)<br>
{<br>
  PyObject *type, *item;<br>
  if (!PyArg_UnpackTuple(args, "__class_getitem__", 2, 2, &type, &item)) {<br>
    return NULL;<br>
  }<br>
  ...<br>
}<br>
<br>
Note an unused parameter and the need of manual unpacking arguments.<br>
<br>
If use it as a class method it should be declared with flags METH_O|METH_CLASS and implemented as<br>
<br>
static PyObject *<br>
generic_class_getitem(PyObject *type, PyObject *item)<br>
{<br>
  ...<br>
}<br>
<br>
See <a href="https://github.com/python/cpython/pull/4883" rel="noreferrer" target="_blank">https://github.com/python/cpyt<wbr>hon/pull/4883</a> for sample.<br>
<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/levkivskyi%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/levkivsky<wbr>i%40gmail.com</a><br>
</blockquote></div><br></div></div></div></div>