[New-bugs-announce] [issue25557] Optimize LOAD_NAME bytecode

STINNER Victor report at bugs.python.org
Thu Nov 5 05:11:19 EST 2015


New submission from STINNER Victor:

The LOAD_GLOBAL bytecode has a fast-path when globals and builtins have exactly the type 'dict'. It calls the _PyDict_LoadGlobal() function.

I propose to implement a similar optimization for LOAD_NAME, see attached patch.

The patch also fixes LOAD_GLOBAL and LOAD_NAME bytecodes when locals, globals or builtins are not exactly the type 'dict'. It clears the KeyError before trying the next PyObject_GetItem().

The patch changes also _PyDict_LoadGlobal() to call PyObject_Hash() if the hash was not computed yet. It might make it a little bit faster.

----------
components: Interpreter Core
files: pydict_loadname.patch
keywords: patch
messages: 254097
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Optimize LOAD_NAME bytecode
type: performance
versions: Python 3.6
Added file: http://bugs.python.org/file40950/pydict_loadname.patch

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


More information about the New-bugs-announce mailing list