summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/frameobject.c22
-rw-r--r--Objects/intobject.c33
2 files changed, 36 insertions, 19 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;
}
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 19d18d3..10587ac 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -78,7 +78,7 @@ fill_free_list(void)
#define NSMALLPOSINTS 100
#endif
#ifndef NSMALLNEGINTS
-#define NSMALLNEGINTS 1
+#define NSMALLNEGINTS 5
#endif
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
/* References to small integers are saved in this array so that they
@@ -97,8 +97,8 @@ PyInt_FromLong(long ival)
{
register PyIntObject *v;
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
- if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS &&
- (v = small_ints[ival + NSMALLNEGINTS]) != NULL) {
+ if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) {
+ v = small_ints[ival + NSMALLNEGINTS];
Py_INCREF(v);
#ifdef COUNT_ALLOCS
if (ival >= 0)
@@ -118,13 +118,6 @@ PyInt_FromLong(long ival)
free_list = (PyIntObject *)v->ob_type;
PyObject_INIT(v, &PyInt_Type);
v->ob_ival = ival;
-#if NSMALLNEGINTS + NSMALLPOSINTS > 0
- if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) {
- /* save this one for a following allocation */
- Py_INCREF(v);
- small_ints[ival + NSMALLNEGINTS] = v;
- }
-#endif
return (PyObject *) v;
}
@@ -945,6 +938,26 @@ PyTypeObject PyInt_Type = {
(freefunc)int_free, /* tp_free */
};
+int
+PyInt_Init(void)
+{
+ PyIntObject *v;
+ int ival;
+#if NSMALLNEGINTS + NSMALLPOSINTS > 0
+ for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) {
+ if ((free_list = fill_free_list()) == NULL)
+ return 0;
+ /* PyObject_New is inlined */
+ v = free_list;
+ free_list = (PyIntObject *)v->ob_type;
+ PyObject_INIT(v, &PyInt_Type);
+ v->ob_ival = ival;
+ small_ints[ival + NSMALLNEGINTS] = v;
+ }
+#endif
+ return 1;
+}
+
void
PyInt_Fini(void)
{