Index: Include/intobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/intobject.h,v retrieving revision 2.26 diff -w -u -r2.26 intobject.h --- Include/intobject.h 12 Aug 2002 07:21:56 -0000 2.26 +++ Include/intobject.h 17 Dec 2002 02:04:49 -0000 @@ -30,6 +30,7 @@ #define PyInt_Check(op) PyObject_TypeCheck(op, &PyInt_Type) #define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) +PyAPI_FUNC(int) PyInt_Init(void); PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); #ifdef Py_USING_UNICODE PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int); Index: Include/pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.56 diff -w -u -r2.56 pythonrun.h --- Include/pythonrun.h 11 Dec 2002 14:04:58 -0000 2.56 +++ Include/pythonrun.h 17 Dec 2002 02:04:49 -0000 @@ -99,6 +99,8 @@ PyAPI_FUNC(PyObject *) _PySys_Init(void); PyAPI_FUNC(void) _PyImport_Init(void); PyAPI_FUNC(void) _PyExc_Init(void); +PyAPI_FUNC(void) _PyImportHooks_Init(void); +PyAPI_FUNC(int) PyFrame_Init(void); /* Various internal finalizers */ PyAPI_FUNC(void) _PyExc_Fini(void); Index: Objects/intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.95 diff -w -u -r2.95 intobject.c --- Objects/intobject.c 19 Nov 2002 20:49:15 -0000 2.95 +++ Objects/intobject.c 17 Dec 2002 02:04:50 -0000 @@ -78,7 +78,7 @@ #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 @@ { 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 @@ 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; } @@ -990,6 +983,26 @@ int_new, /* tp_new */ (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) Index: Objects/frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.67 diff -w -u -r2.67 frameobject.c --- Objects/frameobject.c 11 Sep 2002 15:36:32 -0000 2.67 +++ Objects/frameobject.c 17 Dec 2002 02:04:50 -0000 @@ -133,9 +133,9 @@ } 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); @@ -257,21 +257,23 @@ 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))) { @@ -534,4 +536,6 @@ --numfree; } assert(numfree == 0); + Py_XDECREF(builtin_object); + builtin_object = NULL; }