is implemented with id ?
Aahz
aahz at pythoncraft.com
Sun Nov 4 01:09:24 EDT 2012
In article <mailman.3250.1351999198.27098.python-list at python.org>,
Chris Angelico <rosuav at gmail.com> wrote:
>On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano
><steve+comp.lang.python at pearwood.info> 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 pythoncraft.com) <*> http://www.pythoncraft.com/
"....Normal is what cuts off your sixth finger and your tail..." --Siobhan
More information about the Python-list
mailing list