On 05/09/2012 03:18, Neil Hodgson wrote:
Roy Smith:

I'm wondering if it might be faster to start at the ends of the strings
instead of at the beginning?  If the strings are indeed equal, it's the
same amount of work starting from either end.

     Most people write loops that go forwards. This leads to the
processor designers prioritizing detection mechanisms like cache
prefetching for that case.

     However, its not always the situation: a couple of years ago Intel
contributed a memcpy implementation to glibc that went backwards for a
performance improvement. An explanation from a related patch involves
speculative and committed operations and address bits on some processors
and quickly lost me:
paragraph 3 of
http://lists.freedesktop.org/archives/pixman/2010-August/000423.html

     The memcpy patch was controversial as it broke Adobe Flash which
assumed memcpy was safe like memmove.

I don't think I've ever use memcpy, only memmove.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to