mirror of
https://github.com/python/cpython
synced 2024-09-20 15:21:31 +00:00
Vladimir Marangozov' performance hack: copy f_builtins from ancestor
if the globals are the same. Also, when creating a dummy builtins dictionary, add "None" to it, just to be kind.
This commit is contained in:
parent
3da3fcef96
commit
bde6ff7984
|
@ -164,9 +164,16 @@ PyFrame_New(tstate, code, globals, locals)
|
|||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
if (back == NULL || back->f_globals != globals) {
|
||||
builtins = PyDict_GetItem(globals, builtin_object);
|
||||
if (builtins != NULL && PyModule_Check(builtins))
|
||||
builtins = PyModule_GetDict(builtins);
|
||||
}
|
||||
else {
|
||||
/* If we share the globals, we share the builtins.
|
||||
Save a lookup and a call. */
|
||||
builtins = back->f_builtins;
|
||||
}
|
||||
if (builtins != NULL && !PyDict_Check(builtins))
|
||||
builtins = NULL;
|
||||
if (free_list == NULL) {
|
||||
|
@ -194,9 +201,13 @@ PyFrame_New(tstate, code, globals, locals)
|
|||
_Py_NewReference(f);
|
||||
}
|
||||
if (builtins == NULL) {
|
||||
/* No builtins! Make up a minimal one. */
|
||||
builtins = PyDict_New();
|
||||
if (builtins == NULL)
|
||||
return NULL;
|
||||
/* Give them 'None', at least. */
|
||||
if (PyDict_SetItemString(builtins, "None", Py_None) < 0)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
Py_XINCREF(builtins);
|
||||
|
|
Loading…
Reference in a new issue