Closed
Description
Accessing the __dict__
of an object takes a bit of pointer chasing and computation.
The code to get the address of the __dict__
is as follows:
(assuming we have already checked whether this object can have a dict)
Py_ssize_t dictoffset = tp->tp_dictoffset;
if (dictoffset < 0) {
/* Compute size of object */
Py_ssize_t tsize = ...
dictoffset += size;
}
dictptr = (PyObject **) ((char *)obj + dictoffset);
Given how often we access instance attributes, this overhead is significant
What we would like is:
dictptr = (PyObject **) ((char *)obj + CONSTANT;
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done