Index: Include/intobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/intobject.h,v retrieving revision 2.26 diff -C5 -r2.26 intobject.h *** Include/intobject.h 12 Aug 2002 07:21:56 -0000 2.26 --- Include/intobject.h 13 Sep 2002 15:12:42 -0000 *************** *** 28,37 **** --- 28,38 ---- PyAPI_DATA(PyTypeObject) PyInt_Type; #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); #endif PyAPI_FUNC(PyObject *) PyInt_FromLong(long); Index: Include/pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.54 diff -C5 -r2.54 pythonrun.h *** Include/pythonrun.h 12 Aug 2002 13:06:35 -0000 2.54 --- Include/pythonrun.h 13 Sep 2002 15:12:42 -0000 *************** *** 97,106 **** --- 97,107 ---- /* Internal -- various one-time initializations */ PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); PyAPI_FUNC(PyObject *) _PySys_Init(void); PyAPI_FUNC(void) _PyImport_Init(void); PyAPI_FUNC(void) _PyExc_Init(void); + PyAPI_FUNC(int) PyFrame_Init(void); /* Various internal finalizers */ PyAPI_FUNC(void) _PyExc_Fini(void); PyAPI_FUNC(void) _PyImport_Fini(void); PyAPI_FUNC(void) PyMethod_Fini(void); Index: Objects/frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.67 diff -C5 -r2.67 frameobject.c *** Objects/frameobject.c 11 Sep 2002 15:36:32 -0000 2.67 --- Objects/frameobject.c 13 Sep 2002 15:12:42 -0000 *************** *** 131,143 **** for (p = f->f_valuestack; p < f->f_stacktop; p++) Py_XDECREF(*p); } Py_XDECREF(f->f_back); ! Py_XDECREF(f->f_code); ! Py_XDECREF(f->f_builtins); ! Py_XDECREF(f->f_globals); Py_XDECREF(f->f_locals); Py_XDECREF(f->f_trace); Py_XDECREF(f->f_exc_type); Py_XDECREF(f->f_exc_value); Py_XDECREF(f->f_exc_traceback); --- 131,143 ---- for (p = f->f_valuestack; p < f->f_stacktop; p++) Py_XDECREF(*p); } Py_XDECREF(f->f_back); ! 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); Py_XDECREF(f->f_exc_value); Py_XDECREF(f->f_exc_traceback); *************** *** 255,279 **** frame_getsetlist, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ }; 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))) { PyErr_BadInternalCall(); return NULL; --- 255,281 ---- frame_getsetlist, /* tp_getset */ 0, /* tp_base */ 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; PyFrameObject *f; PyObject *builtins; int extras, ncells, nfrees; #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || (locals != NULL && !PyDict_Check(locals))) { PyErr_BadInternalCall(); return NULL; Index: Objects/intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.93 diff -C5 -r2.93 intobject.c *** Objects/intobject.c 11 Sep 2002 19:00:52 -0000 2.93 --- Objects/intobject.c 13 Sep 2002 15:12:43 -0000 *************** *** 76,86 **** #ifndef NSMALLPOSINTS #define NSMALLPOSINTS 100 #endif #ifndef NSMALLNEGINTS ! #define NSMALLNEGINTS 1 #endif #if NSMALLNEGINTS + NSMALLPOSINTS > 0 /* References to small integers are saved in this array so that they can be shared. The integers that are saved are those in the range --- 76,86 ---- #ifndef NSMALLPOSINTS #define NSMALLPOSINTS 100 #endif #ifndef NSMALLNEGINTS ! #define NSMALLNEGINTS 5 #endif #if NSMALLNEGINTS + NSMALLPOSINTS > 0 /* References to small integers are saved in this array so that they can be shared. The integers that are saved are those in the range *************** *** 95,106 **** PyObject * PyInt_FromLong(long ival) { register PyIntObject *v; #if NSMALLNEGINTS + NSMALLPOSINTS > 0 ! if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS && ! (v = small_ints[ival + NSMALLNEGINTS]) != NULL) { Py_INCREF(v); #ifdef COUNT_ALLOCS if (ival >= 0) quick_int_allocs++; else --- 95,106 ---- PyObject * PyInt_FromLong(long ival) { register PyIntObject *v; #if NSMALLNEGINTS + NSMALLPOSINTS > 0 ! if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) { ! v = small_ints[ival + NSMALLNEGINTS]; Py_INCREF(v); #ifdef COUNT_ALLOCS if (ival >= 0) quick_int_allocs++; else *************** *** 116,132 **** /* Inline PyObject_New */ v = free_list; 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; } static void int_dealloc(PyIntObject *v) --- 116,125 ---- *************** *** 974,983 **** --- 967,997 ---- 0, /* tp_init */ 0, /* tp_alloc */ 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; + Py_INCREF(v); + small_ints[ival + NSMALLNEGINTS] = v; + } + #endif + return 1; + } void PyInt_Fini(void) { PyIntObject *p; Index: Python/pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.166 diff -C5 -r2.166 pythonrun.c *** Python/pythonrun.c 15 Aug 2002 01:20:16 -0000 2.166 --- Python/pythonrun.c 13 Sep 2002 15:12:43 -0000 *************** *** 122,131 **** --- 122,137 ---- Py_FatalError("Py_Initialize: can't make first thread"); (void) PyThreadState_Swap(tstate); _Py_ReadyTypes(); + if (!PyFrame_Init()) + Py_FatalError("Py_Initialize: can't init frames"); + + if (!PyInt_Init()) + Py_FatalError("Py_Initialize: can't init ints"); + interp->modules = PyDict_New(); if (interp->modules == NULL) Py_FatalError("Py_Initialize: can't make modules dictionary"); /* Init codec registry */