[issue10160] operator.attrgetter slower than lambda after adding dotted names ability
Χρήστος Γεωργίου (Christos Georgiou)
report at bugs.python.org
Thu Oct 21 08:56:01 CEST 2010
Χρήστος Γεωργίου (Christos Georgiou) <tzot at users.sourceforge.net> added the comment:
Modules/operator.c grows by ~70 lines, most of it the setup code for ag->attr; also I loop twice over the args of attrgetter_new, choosing fast code that runs once per attrgetter creation than temporary data.
Alex's suggestion to make use of Python-level functions to shorten the code of attrgetter_new could obviously work to decrease the source lines. I don't know how fast I would produce such a version if requested, though.
Whatever the way attrgetter_new sets up the data, I would suggest that you keep the logic changes in general, i.e. set-up in attrgetter_new and keep a thinner dotted_getattr , since it avoids running the same checks and splitting over and over again for every attrgetter_call invocation.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list