[Python-3000] Where is PyUnicodeObject->hash supposed to be set? (original) (raw)

Guido van Rossum guido at python.org
Fri Sep 7 20:46:28 CEST 2007


It should be set in unicode_hash(). If you compare the trunk version of that function with the py3k branch version, you see that it's been refactored, and in the refactoring, setting ->hash was omitted. It should be trivial to put it back.

On 9/7/07, Nicholas Bastin <nick.bastin at gmail.com> wrote:

Before I do a bunch of searching around in the source, perhaps someone just knows the answer to this question.

A quick trip through the debugger indicates that the reason PyDictGetItem is being called 5 million times more often in PyEvalEvalFrameEx in 3.0 (in pystone 100000) is because while PyStringCheckExact was swapped out for PyUnicodeCheckExact in LOADGLOBAL, ((PyUnicodeObject*)w)->hash always evaluates to -1, which punts us down to the non-inline code. Presumably ((PyStringObject*)w)->obshash was already set at this point, which is why it worked in 2.6 and previous. Before I spend a lot of time trying to track down where this is supposed to be getting set (or, needs to be being set), does anyone know where this is supposed to happen? -- Nick


Python-3000 mailing list Python-3000 at python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-3000 mailing list