On Sun, Jun 18, 2000 at 09:06:45PM +0200, Fredrik Lundh wrote: >so in other words, something in unicode land isn't >as efficient as it should... The relevant bit of findstring() in unicodeobject.c: if (direction < 0) { for (; end >= start; end--) if (Py_UNICODE_MATCH(self, end, substring)) return end; } else { for (; start <= end; start++) if (Py_UNICODE_MATCH(self, start, substring)) return start; } And... #define Py_UNICODE_MATCH(string, offset, substring)\ (!memcmp((string)->str + (offset), (substring)->str,\ (substring)->length*sizeof(Py_UNICODE))) Proposed patch: Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.26 diff -u -r2.26 unicodeobject.c --- unicodeobject.c 2000/06/14 09:18:32 2.26 +++ unicodeobject.c 2000/06/18 19:18:01 @@ -2168,11 +2168,13 @@ if (direction < 0) { for (; end >= start; end--) - if (Py_UNICODE_MATCH(self, end, substring)) + if ( *(self->str + end) == *(substring->str) && + Py_UNICODE_MATCH(self, end, substring)) return end; } else { for (; start <= end; start++) - if (Py_UNICODE_MATCH(self, start, substring)) + if (*(self->str + start) == *(substring->str) && + Py_UNICODE_MATCH(self, start, substring)) return start; } --amk
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4