Skip to content

bpo-32346: speed up slot lookup during class creation #4902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,9 @@ type objects) *must* have the :attr:`ob_size` field.
.. seealso:: "Safe object finalization" (:pep:`442`)


.. c:member:: PyObject* PyTypeObject.tp_cache
.. c:member:: PyObject* PyTypeObject.tp_defined_slots

Unused. Not inherited. Internal use only.
Not inherited. Internal use only.


.. c:member:: PyObject* PyTypeObject.tp_subclasses
Expand Down
2 changes: 1 addition & 1 deletion Doc/includes/typestruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef struct _typeobject {
inquiry tp_is_gc; /* For PyObject_IS_GC */
PyObject *tp_bases;
PyObject *tp_mro; /* method resolution order */
PyObject *tp_cache;
PyObject *tp_defined_slots;
PyObject *tp_subclasses;
PyObject *tp_weaklist;
destructor tp_del;
Expand Down
2 changes: 1 addition & 1 deletion Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ typedef struct _typeobject {
inquiry tp_is_gc; /* For PyObject_IS_GC */
PyObject *tp_bases;
PyObject *tp_mro; /* method resolution order */
PyObject *tp_cache;
PyObject *tp_defined_slots; /* internal cache; changed in version 3.7 */
PyObject *tp_subclasses;
PyObject *tp_weaklist;
destructor tp_del;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Speed up slot lookup during class creation
10 changes: 5 additions & 5 deletions Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ PyTypeObject PyBufferedIOBase_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -2466,7 +2466,7 @@ PyTypeObject PyBufferedReader_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -2553,7 +2553,7 @@ PyTypeObject PyBufferedWriter_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -2632,7 +2632,7 @@ PyTypeObject PyBufferedRWPair_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -2727,7 +2727,7 @@ PyTypeObject PyBufferedRandom_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ PyTypeObject PyFileIO_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
4 changes: 2 additions & 2 deletions Modules/_io/iobase.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ PyTypeObject PyIOBase_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -1026,7 +1026,7 @@ PyTypeObject PyRawIOBase_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
4 changes: 2 additions & 2 deletions Modules/_io/textio.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ PyTypeObject PyTextIOBase_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -3202,7 +3202,7 @@ PyTypeObject PyTextIOWrapper_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/winconsoleio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ PyTypeObject PyWindowsConsoleIO_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -12141,7 +12141,7 @@ static PyTypeObject ScandirIteratorType = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
2 changes: 1 addition & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4925,7 +4925,7 @@ static PyTypeObject sock_type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
6 changes: 3 additions & 3 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ PyTypeObject PyGen_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -1062,7 +1062,7 @@ PyTypeObject PyCoro_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down Expand Up @@ -1407,7 +1407,7 @@ PyTypeObject PyAsyncGen_Type = {
0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
0, /* tp_defined_slots */
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
Expand Down
Loading