[issue10359] ISO C cleanup

Hallvard B Furuseth report at bugs.python.org
Tue Nov 9 10:54:44 CET 2010


Hallvard B Furuseth <h.b.furuseth at usit.uio.no> added the comment:

STINNER Victor writes:
> Python-ast.c: why do you move req_name and req_type outside PyAST_obj2mod()?

Because there's no need to initialize the arrays each time PyAST_obj2mod
is called.  C90-friendly code inside PyAST_obj2mod would be

PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
{
    mod_ty res;
    static char *const req_name[] = {"Module", "Expression", "Interactive"};
    PyObject *req_type[];
    req_type[0] = (PyObject*)Module_type;
    req_type[1] = (PyObject*)Expression_type;
    req_type[2] = (PyObject*)Interactive_type;
    ...
}

which is what the current code actually executes.

(I moved req_name to keep it next to req_type in the code.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10359>
_______________________________________


More information about the Python-bugs-list mailing list