deque vs list: performance notes

Courageous jkraska1 at san.rr.com
Sun Jun 4 15:18:03 EDT 2000


> >     if ((dlist->vfront < 1) && (dlist->len < (2*dlist->alloclen/3)))
> >     {
> >         DlistReposition(dlist);
> >         dlist->vfront--;
> >         dlist->items[dlist->vfront]=object;
> >     }
> >     else if (dlist->vfront < 1)
> >     {
> >         DlistGrow(dlist);
> >         dlist->vfront--;
> >         dlist->items[dlist->vfront]=object;
> >     }
> >     else
> >     {
> >         dlist->vfront--;
> >         dlist->items[dlist->vfront]=object;
> >     }

Klaus Baldermann correctly pointed out that the following code is
both more clear/succinct and slightly more efficient:

    if (dlist->vfront < 1)
    {
        if (dlist->len < 2*dlist->alloclen/3) DlistReposition(dlist);
        else                                  DlistGrow(dlist);
    }
    dlist->vfront--;
    dlist->items[dlist->vfront]=object;
    dlist->len++;

I made substantial progress last night. Left to do is slice assignment,
sorting, creation of the immutable type to prevent modifaction during
sort, and slightly reimplementing the functions to match the same
available profiles of listobject.c methods.

I implemented concatenate to handle either dlist/dlist combinations
or dlist/list combinations, which is a nice feature, because it
allows you to fold a python list produced by third party software
into an empty dlist; it would also be possible to allow my deque
implementation to be concatenated in as well, but I didn't do it,
because I didn't want to force the module dependency.

Is there any regression testing software for python lists anywhere?
It's getting a bit hairy to verify everything now, and I'm
writing more and more of my own regression testing code.




C/



More information about the Python-list mailing list