[Python-checkins] python/dist/src/Misc ACKS, 1.254, 1.255 NEWS, 1.915, 1.916

aimacintyre at users.sourceforge.net aimacintyre at users.sourceforge.net
Thu Dec 25 08:28:51 EST 2003


Update of /cvsroot/python/python/dist/src/Misc
In directory sc8-pr-cvs1:/tmp/cvs-serv6382

Modified Files:
	ACKS NEWS 
Log Message:
Performance of list([]) in 2.3 came up in a thread on comp.lang.python,
which can be reviewed via
http://coding.derkeiler.com/Archive/Python/comp.lang.python/2003-12/1011.html

Duncan Booth investigated, and discovered that an "optimisation" was
in fact a pessimisation for small numbers of elements in a source list,
compared to not having the optimisation, although with large numbers
of elements in the source list the optimisation was quite beneficial.

He posted his change to comp.lang.python (but not to SF).

Further research has confirmed his assessment that the optimisation only
becomes a net win when the source list has more than 100 elements.

I also found that the optimisation could apply to tuples as well,
but the gains only arrive with source tuples larger than about 320
elements and are nowhere near as significant as the gains with lists,
(~95% gain @ 10000 elements for lists, ~20% gain @ 10000 elements for
tuples) so I haven't proceeded with this.

The code as it was applied the optimisation to list subclasses as
well, and this also appears to be a net loss for all reasonable sized
sources (~80-100% for up to 100 elements, ~20% for more than 500
elements; I tested up to 10000 elements).

Duncan also suggested special casing empty lists, which I've extended
to all empty sequences.

On the basis that list_fill() is only ever called with a list for the
result argument, testing for the source being the destination has
now happens before testing source types.


Index: ACKS
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v
retrieving revision 1.254
retrieving revision 1.255
diff -C2 -d -r1.254 -r1.255
*** ACKS	10 Nov 2003 06:44:44 -0000	1.254
--- ACKS	25 Dec 2003 13:28:48 -0000	1.255
***************
*** 63,66 ****
--- 63,67 ----
  Matthew Boedicker
  David Bolen
+ Duncan Booth
  Jurjen Bos
  Peter Bosch

Index: NEWS
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v
retrieving revision 1.915
retrieving revision 1.916
diff -C2 -d -r1.915 -r1.916
*** NEWS	17 Dec 2003 20:43:32 -0000	1.915
--- NEWS	25 Dec 2003 13:28:48 -0000	1.916
***************
*** 119,122 ****
--- 119,130 ----
    working towards the beginning.  See SF feature request 801847.
  
+ - in a thread on comp.lang.python, several people noted that list()
+   was much slower than in 2.1 and earlier versions of Python, when used
+   to create new lists from existing lists.  Duncan Booth did some
+   research that uncovered an optimisation that, for lists below
+   about 100 elements, was actually slower than the normal case. The
+   special case criteria have been tightened to rectify the performance
+   regression.
+ 
  Extension modules
  -----------------





More information about the Python-checkins mailing list