Issue #19512: add some common identifiers to only create common strings once,

instead of creating temporary Unicode string objects

Add also more identifiers in pythonrun.c to avoid temporary Unicode string
objets for the interactive interpreter.
This commit is contained in:
Victor Stinner 2013-11-06 22:41:44 +01:00
parent bb52020d44
commit 090543736f
13 changed files with 72 additions and 49 deletions

View file

@ -143,9 +143,17 @@ typedef struct _Py_Identifier {
PyObject *object;
} _Py_Identifier;
#define _Py_static_string(varname, value) static _Py_Identifier varname = { 0, value, 0 }
#define _Py_static_string_init(value) { 0, value, 0 }
#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value)
#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
/* Common identifiers */
PyAPI_DATA(_Py_Identifier) _PyId_path;
PyAPI_DATA(_Py_Identifier) _PyId_argv;
PyAPI_DATA(_Py_Identifier) _PyId_stdin;
PyAPI_DATA(_Py_Identifier) _PyId_stdout;
PyAPI_DATA(_Py_Identifier) _PyId_stderr;
/*
Type objects contain a string containing the type name (to help somewhat
in debugging), the allocation parameters (see PyObject_New() and
@ -829,7 +837,7 @@ PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
PyObject *_py_xincref_tmp = (PyObject *)(op); \
if (_py_xincref_tmp != NULL) \
Py_INCREF(_py_xincref_tmp); \
} while (0)
} while (0)
#define Py_XDECREF(op) \
do { \