[Patches] [Patch #101394] lookdict optimizations
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 5 Sep 2000 06:08:22 -0700
Patch #101394 has been updated.
Project:
Category: core (C code)
Status: Open
Summary: lookdict optimizations
Follow-Ups:
Date: 2000-Sep-03 21:09
By: marangoz
Comment:
Let's add a comment, although this has been raised on python-dev.
This patch proposes a couple of ideas for optimizing & speeding dict
lookups -- not all of them need to be applied though.
- clear the eventual errors from Object_Compare only on need
(this logic needs to be double-checked once again to see whether it
really works)
- defer variable initializations after the most common return cases
- specialize string_compare() for lookdict_string. The test comparing
the first char, before calling memcmp(), can be added too.
- inline the first item probe in PyDict_GetItem. This saves a func call
for the most common case (common to lookdict & lookdict_string).
-------------------------------------------------------
Date: 2000-Sep-04 06:45
By: gvanrossum
Comment:
Quick comments: we should *always* call PyErr_Occurred() after PyObject_Compare() (and PyErr_Clear() if PyErr_Occurred() returned true). PyErr_Compare() really doesn't expect a pending exception coming in and so *not* clearing the error might break the *next* PyErr_Compare() call. (This doesn't happen typically but PyObject_Compare() can execute arbitrary code, some of which might call PyErr_Occurred() without calling PyErr_Clear() first.)
-------------------------------------------------------
Date: 2000-Sep-05 06:05
By: none
Comment:
Correct!
But then, aren't the current "else" if(cmp == 0) clauses risky after
PyObject_Compare()? An exception may be set in external code
while making Object_Compare() to return 0! Perhaps not in Python
source, but in buggy extensions. lookdict() will then overlook this "hit".
Patch updated, without "else" clauses and with the 1st char check in
string_compare_equal().
-------------------------------------------------------
Date: 2000-Sep-05 06:08
By: marangoz
Comment:
Argh! These Web interfaces strike again - forgot to login.
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=101394&group_id=5470