GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • [ date ]
  • [ thread ]
  • [ subject ]
  • [ author ]

This view

  • Original page
  • New address

GeezerVison is showing mail.python.org — [Python-Dev] Make __class_getitem__ a class method

[Python-Dev] Make __class_getitem__ a class method

Ivan Levkivskyi levkivskyi at gmail.com
Fri Dec 15 18:00:47 EST 2017

  • Previous message (by thread): [Python-Dev] Make __class_getitem__ a class method
  • Next message (by thread): [Python-Dev] New crash in test_embed on macOS 10.12
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

On 15 December 2017 at 19:35, Serhiy Storchaka <storchaka at gmail.com> wrote:

> 15.12.17 20:02, Yury Selivanov пише:
>
>> But nobody decorates __new__ with a @staticmethod.  And making
>> __class_getitem__ a @classmethod will only confuse users -- that's all
>> I'm saying.
>>
>> So I'm +1 to keep the things exactly as they are now.  It would be
>> great do document that in order to implement __class_getitem__ in C
>> one should add it as METH_STATIC.  I also think we should merge your
>> PR that tests that it works the way it's expected.
>>
>
> In this case I suggest to make __class_getitem__ an automatic class method
> like __init_subclass__.
>
> The number of special cases bothers me.
>

I just want to clarify what is proposed. As I understand:

* From the point of view of a pure Python class there will be no difference
with the current behaviour, one just writes

      class C:
          def __class_getitem__(cls, item):
              ...

*  In `type_new`, `__class_getitem__` will be wrapped in classmethod
*  From the point of view of C extensions one will use METH_CLASS and no
tuple unpacking

If this is true that this looks reasonable. If no-one is against, then I
can make a PR.
The only downside to this that I see is that `type.__new__` will be
slightly slower.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171216/128d8c55/attachment.html>

  • Previous message (by thread): [Python-Dev] Make __class_getitem__ a class method
  • Next message (by thread): [Python-Dev] New crash in test_embed on macOS 10.12
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the Python-Dev mailing list
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.