[Python-checkins] r81706 - in python/trunk: Lib/test/test_descr.py Objects/abstract.c
Nick Coghlan
ncoghlan at gmail.com
Sat Jun 5 10:08:05 CEST 2010
On 05/06/10 10:32, benjamin.peterson wrote:
> - /* Initialize cached value */
> - if (str__format__ == NULL) {
> - /* Initialize static variable needed by _PyType_Lookup */
> - str__format__ = PyString_InternFromString("__format__");
> - if (str__format__ == NULL)
> - goto done;
> - }
> -
Why kill the microoptimisation here? Looking the string up in the intern
dict every time (as these changes do) is a waste of cycles. Since
avoiding it is pretty easy using this common idiom, it's generally worth
doing.
I suggest restoring the microoptimisation and then rewriting the
_PyObject_LookupSpecial call to prepopulate the object:
_PyObject_LookupSpecial(obj, NULL, str__format)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
More information about the Python-checkins
mailing list