summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-12-30 22:29:22 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-12-30 22:29:22 (GMT)
commitc91ed400e053dc9f11dd30c84e2bb611999dce50 (patch)
treef190a1d4d9d3dbdb7d60afda9f7ea643e4f63b1b /Objects/frameobject.c
parent83f898c86c5ce68eaddd8f729a67ae2d7d0666ec (diff)
downloadcpython-c91ed400e053dc9f11dd30c84e2bb611999dce50.zip
cpython-c91ed400e053dc9f11dd30c84e2bb611999dce50.tar.gz
cpython-c91ed400e053dc9f11dd30c84e2bb611999dce50.tar.bz2
SF #561244, Micro optimizations
Initialize the small integers and __builtins__ in startup. This removes some if conditions. Change XDECREF to DECREF for values which shouldn't be NULL.
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 9123d94..b982064 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -401,9 +401,9 @@ frame_dealloc(PyFrameObject *f)
}
Py_XDECREF(f->f_back);
- Py_XDECREF(f->f_code);
- Py_XDECREF(f->f_builtins);
- Py_XDECREF(f->f_globals);
+ Py_DECREF(f->f_code);
+ Py_DECREF(f->f_builtins);
+ Py_DECREF(f->f_globals);
Py_XDECREF(f->f_locals);
Py_XDECREF(f->f_trace);
Py_XDECREF(f->f_exc_type);
@@ -525,21 +525,23 @@ PyTypeObject PyFrame_Type = {
0, /* tp_dict */
};
+static PyObject *builtin_object;
+
+int PyFrame_Init()
+{
+ builtin_object = PyString_InternFromString("__builtins__");
+ return (builtin_object != NULL);
+}
+
PyFrameObject *
PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,
PyObject *locals)
{
PyFrameObject *back = tstate->frame;
- static PyObject *builtin_object;
PyFrameObject *f;
PyObject *builtins;
int extras, ncells, nfrees;
- if (builtin_object == NULL) {
- builtin_object = PyString_InternFromString("__builtins__");
- if (builtin_object == NULL)
- return NULL;
- }
#ifdef Py_DEBUG
if (code == NULL || globals == NULL || !PyDict_Check(globals) ||
(locals != NULL && !PyDict_Check(locals))) {
@@ -802,4 +804,6 @@ PyFrame_Fini(void)
--numfree;
}
assert(numfree == 0);
+ Py_XDECREF(builtin_object);
+ builtin_object = NULL;
}