is implemented with id ?

Aahz aahz at
Sun Nov 4 06:09:24 CET 2012

In article <mailman.3250.1351999198.27098.python-list at>,
Chris Angelico  <rosuav at> wrote:
>On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano
><steve+comp.lang.python at> wrote:
>> /* Shortcut for empty or interned objects */
>> if (v == u) {
>>     Py_DECREF(u);
>>     Py_DECREF(v);
>>     return 0;
>> }
>> result = unicode_compare(u, v);
>> where v and u are pointers to the unicode object.
>There's a shortcut if they're the same. There's no shortcut if they're
>both interned and have different pointers, which is a guarantee that
>they're distinct strings. They'll still be compared char-for-char
>until there's a difference.

Without looking at the code, I'm pretty sure there's a hash check first.
Aahz (aahz at           <*>

"....Normal is what cuts off your sixth finger and your tail..."  --Siobhan

More information about the Python-list mailing list