[Python-Dev] Recent experience with the _ast module

"Martin v. Löwis" martin at v.loewis.de
Wed Feb 14 10:23:24 CET 2007


Greg Ewing schrieb:
> It would seem even easier (and a lot faster) to use an
> array to go from C enum --> some object, which could
> as well be an interned string as anything else.

Have you actually looked at the code? How could it be
faster than

PyObject* ast2obj_boolop(boolop_ty o)
{
         switch(o) {
                 case And:
                         Py_INCREF(And_singleton);
                         return And_singleton;
                 case Or:
                         Py_INCREF(Or_singleton);
                         return Or_singleton;
         }
         return NULL; /* cannot happen */
}

Not sure what interned strings have to do with it.

Regards,
Martin


More information about the Python-Dev mailing list