[Python-Dev] Re: [Python-checkins] python/dist/src/Objects
listobject.c, 2.172, 2.173
andymac at bullseye.apana.org.au
Sat Dec 27 18:26:59 EST 2003
On Fri, 26 Dec 2003, Jeremy Hylton wrote:
> > Modified Files:
> > listobject.c
> > Log Message:
> > Revert previous two checkins to repair test failure.
> > The special-case code that was removed could return a value indicating
> > success but leave an exception set. test_fileinput failed in a debug
> > build as a result.
> If there's some value to the optimization I just removed, let's discuss
> it on python-dev. I could have fixed the new code, but it seems a lot
> of hairy new code with magic constants that only covered a few corner
> cases. The checkin message pointed to a python-list discussion that
> didn't have much real evidence in it.
While Duncan Booth's tests didn't properly account for setup overhead and
his coverage of the range of source element counts insufficient, the
performance difference between the two approaches is real and can be
quite significant - list_ass_slice() is a big win for large source lists,
and a non-trivial loss for small lists (>35% for 10 or fewer elements,
>14% up to 64 elements).
The change was an attempt to maximise the performance for all cases.
If performance of list() is not seen as particularly crucial, then I would
suggest that the special case calling of list_ass_slice() should probably
be removed completely.
The special casing of empty source sequences is not really important IMO,
but the timings looked good...
Some of the interest in this area comes from that class of Python user
who wants to make a shallow copy of a list, and looks for a copy() method
on list objects, and failing that finds copy.copy(). Some of them
eventually twig that list() also does this, and doesn't require importing
the copy module. These users don't feel comfortable with the slice
approach, despite the fact that it is considerably faster. In fact I just
noticed a posting to python-list/c.l.p from Alex Martelli in which he
suggests list() is not unreasonable to use for this purpose. I don't have
any problem with the slice, myself.
While I tested the change extensively, I'll confess to not trying a debug
BTW, my ISP's dialin is playing silly buggers at the moment, so I'm not
seeing email in a timely fashion. :-( That's not an excuse for the
PyDict_CheckExact goof, because I saw that checkin msg and still
managed not to see the problem, and hadn't gotten around to building from
a fresh CVS checkout :-( Thanks for fixing that.
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au (pref) | Snail: PO Box 370
andymac at pcug.org.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
More information about the Python-Dev