[Python-Dev] lookdict

Guido van Rossum guido@beopen.com
Fri, 01 Sep 2000 17:04:48 -0500

> Right. I was too fast. There is some speedup due to the string
> specialization. I'll post a patch to SF with some more tweaks
> of this implementation. Briefly:
> - do not call PyErr_Clear() systematically after PyObject_Compare();
>   only if (!error_restore && PyErr_Occurred())

What do you mean?  The lookdict code checked in already checks

> - defer variable initializations after common return cases
> - avoid using more vars in lookdict_string + specialize string_compare()
> - inline the most frequest case in PyDict_GetItem (the first item probe)


> Hm. Question: is it possible for the thread state to swap during
> PyObject_Compare()? If it is possible, things are more complicated
> than I thought...

Doesn't matter -- it will always swap back.  It's tied to the
interpreter lock.

Now, for truly devious code dealing with the lock and thread state,
see the changes to _PyPclose() that Tim Peters just checked in...

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)