[Python-Dev] talking about performance...

M.-A. Lemburg mal@lemburg.com
Sun, 18 Jun 2000 23:48:32 +0200


Fredrik Lundh wrote:
> 
> amk wrote:
> 
> > 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)))
> 
> heh.  it's my own code, of course...
> 
> > Proposed patch:
> >
> > Index: unicodeobject.c
> 
> MATCH is used in a couple of places; it's probably a better idea
> to change the macro (in Include/unicodeobject.h).  MAL?

Right. I'll add Andrew's proposed patch to the macro def.

--
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/