diff options
author | Guido van Rossum <guido@python.org> | 2002-08-19 16:50:48 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-08-19 16:50:48 (GMT) |
commit | c66ff4441e7c4806ff9a73a42ab9229a1988b8df (patch) | |
tree | 53a37ef715b1c2221341b46add6f235e5d6f2609 /Objects/object.c | |
parent | 0b650d756572e33c923eb4998224da2d95dffaac (diff) | |
download | cpython-c66ff4441e7c4806ff9a73a42ab9229a1988b8df.zip cpython-c66ff4441e7c4806ff9a73a42ab9229a1988b8df.tar.gz cpython-c66ff4441e7c4806ff9a73a42ab9229a1988b8df.tar.bz2 |
Inline call to _PyObject_GetDictPtr() in PyObject_GenericGetAttr().
This causes a modest speedup.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c index 70ff3ed..5120eb5 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1292,6 +1292,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) PyObject *descr; PyObject *res = NULL; descrgetfunc f; + long dictoffset; PyObject **dictptr; if (!PyString_Check(name)){ @@ -1330,9 +1331,25 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) } } - dictptr = _PyObject_GetDictPtr(obj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; + /* Inline _PyObject_GetDictPtr */ + dictoffset = tp->tp_dictoffset; + if (dictoffset != 0) { + PyObject *dict; + if (dictoffset < 0) { + int tsize; + size_t size; + + tsize = ((PyVarObject *)obj)->ob_size; + if (tsize < 0) + tsize = -tsize; + size = _PyObject_VAR_SIZE(tp, tsize); + + dictoffset += (long)size; + assert(dictoffset > 0); + assert(dictoffset % SIZEOF_VOID_P == 0); + } + dictptr = (PyObject **) ((char *)obj + dictoffset); + dict = *dictptr; if (dict != NULL) { res = PyDict_GetItem(dict, name); if (res != NULL) { |