diff options
author | INADA Naoki <songofacandy@gmail.com> | 2016-12-24 11:19:08 (GMT) |
---|---|---|
committer | INADA Naoki <songofacandy@gmail.com> | 2016-12-24 11:19:08 (GMT) |
commit | 5a625d0aa6a6d9ec6574ee8344b41d63dcb9897e (patch) | |
tree | 10b9bb211b5cfdd80e1f42757f2773acd3d7f3cd /Objects | |
parent | 2585443b6fc83dade775d2c18bfc2fd70dfde369 (diff) | |
download | cpython-5a625d0aa6a6d9ec6574ee8344b41d63dcb9897e.zip cpython-5a625d0aa6a6d9ec6574ee8344b41d63dcb9897e.tar.gz cpython-5a625d0aa6a6d9ec6574ee8344b41d63dcb9897e.tar.bz2 |
Issue #29049: Call _PyObject_GC_TRACK() lazily when calling Python function.
Calling function is up to 5% faster.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/frameobject.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c index eed5384..8448319 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -415,7 +415,9 @@ frame_dealloc(PyFrameObject *f) PyObject **p, **valuestack; PyCodeObject *co; - PyObject_GC_UnTrack(f); + if (_PyObject_GC_IS_TRACKED(f)) + _PyObject_GC_UNTRACK(f); + Py_TRASHCAN_SAFE_BEGIN(f) /* Kill all local variables */ valuestack = f->f_valuestack; @@ -606,8 +608,8 @@ int _PyFrame_Init() } PyFrameObject* _Py_HOT_FUNCTION -PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, - PyObject *locals) +_PyFrame_New_NoTrack(PyThreadState *tstate, PyCodeObject *code, + PyObject *globals, PyObject *locals) { PyFrameObject *back = tstate->frame; PyFrameObject *f; @@ -727,10 +729,20 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, f->f_executing = 0; f->f_gen = NULL; - _PyObject_GC_TRACK(f); return f; } +PyFrameObject* +PyFrame_New(PyThreadState *tstate, PyCodeObject *code, + PyObject *globals, PyObject *locals) +{ + PyFrameObject *f = _PyFrame_New_NoTrack(tstate, code, globals, locals); + if (f) + _PyObject_GC_TRACK(f); + return f; +} + + /* Block management */ void |