This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pablogsal
Recipients nascheme, pablogsal, rhettinger, vstinner
Date 2019-02-16.23:34:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550360084.44.0.674129423506.issue36012@roundup.psfhosted.org>
In-reply-to
Content
It seems 50% of the overhead (50ns) is due to two reasons:

- 30-40% is due to the call to update_slot(type, name) after the item is set in the class dictionary.

- 70-60% is due to all the extra work from _PyObject_GenericSetAttrWithDict until it ends calling  _PyObjectDict_SetItem with the slot. If in the code of typeobject.c:type_setattro you change:

res = _PyObject_GenericSetAttrWithDict((PyObject *)type, name, value, NULL);

by 

PyObject* dictptr = _PyObject_GetDictPtr(type);
res = _PyObjectDict_SetItem(type, dictptr, name, value);

and delete the update_slot(type, name) call afterwards, the times are reduced to 50ns.
History
Date User Action Args
2019-02-16 23:34:44pablogsalsetrecipients: + pablogsal, nascheme, rhettinger, vstinner
2019-02-16 23:34:44pablogsalsetmessageid: <1550360084.44.0.674129423506.issue36012@roundup.psfhosted.org>
2019-02-16 23:34:44pablogsallinkissue36012 messages
2019-02-16 23:34:44pablogsalcreate