On 4/11/12 06:09:24, Aahz wrote: > In article <mailman.3250.1351999198.27098.python-l...@python.org>, > Chris Angelico <ros...@gmail.com> wrote: >> On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano >> <steve+comp.lang.pyt...@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.
In 3.3, there is no such check. It was recently proposed on python-dev to add such a check, but AFAIK, no action was taken. -- HansM -- http://mail.python.org/mailman/listinfo/python-list