]> granicus.if.org Git - python/commit
Another ugly inlining hack, expanding the two PyDict_GetItem() calls
authorGuido van Rossum <guido@python.org>
Mon, 19 Aug 2002 20:24:07 +0000 (20:24 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 19 Aug 2002 20:24:07 +0000 (20:24 +0000)
commit3a4dfc87e68c8158110145df12109b155eea16e4
tree8388079a1d0dee44bc830ad8b4873ceeb1e12438
parente3a8e7ed1d221e5c19d0b3cd9796b393bc41dc68
Another ugly inlining hack, expanding the two PyDict_GetItem() calls
in LOAD_GLOBAL.  Besides saving a C function call, it saves checks
whether f_globals and f_builtins are dicts, and extracting and testing
the string object's hash code is done only once.  We bail out of the
inlining if the name is not exactly a string, or when its hash is -1;
because of interning, neither should ever happen.  I believe interning
guarantees that the hash code is set, and I believe that the 'names'
tuple of a code object always contains interned strings, but I'm not
assuming that -- I'm simply testing hash != -1.

On my home machine, this makes a pystone variant with new-style
classes and slots run at the same speed as classic pystone!  (With
new-style classes but without slots, it is still a lot slower.)
Python/ceval.c