[issue39754] update_one_slot() does not inherit sq_contains and mp_subscript if they are explictly declared

2020-02-26 Thread Marco Sulla


Change by Marco Sulla :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39754] update_one_slot() does not inherit sq_contains and mp_subscript if they are explictly declared

2020-02-25 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

See also #34396.

--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39754] update_one_slot() does not inherit sq_contains and mp_subscript if they are explictly declared

2020-02-25 Thread Marco Sulla


New submission from Marco Sulla :

I noticed that `__contains__()` and `__getitem__()` of subclasses of `dict` are 
much slower. I asked why on StackOverflow, and an user seemed to find the 
reason.

The problem for him/her is that `dict` implements directly `__contains__()` and 
`__getitem__()`. Usually, `sq_contains` and `mp_subscript` are wrapped to 
implement `__contains__()` and `__getitem__()`, but this way `dict` is a little 
faster, I suppose.

The problem is that `update_one_slot()` searches for the wrappers. If it does 
not find them, it does not inherit the `__contains__()` and `__getitem__()` of 
the class, but create a `__contains__()` and `__getitem__()` functions that do 
an MRO search and call the superclass method. This is why `__contains__()` and 
`__getitem__()` of `dict` subclasses are slower.


Is it possible to modify `update_one_slot()` so that, if no wrapper is found, 
the explicit implementation is inherited?

SO answer: https://stackoverflow.com/a/59914459/1763602

--
components: C API
messages: 362662
nosy: Marco Sulla
priority: normal
severity: normal
status: open
title: update_one_slot() does not inherit sq_contains and mp_subscript if they 
are explictly declared
type: performance
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com