[Patches] [ python-Patches-633870 ] allow any seq assignment to a list slice

noreply@sourceforge.net noreply@sourceforge.net
Tue, 05 Nov 2002 09:12:23 -0800


Patches item #633870, was opened at 2002-11-05 10:59
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=633870&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Alex Martelli (aleax)
>Assigned to: Michael Hudson (mwh)
Summary: allow any seq assignment to a list slice

Initial Comment:
as suggested by Michael Hudson in his comp.lang.python 
post of Tue, 5 Nov 2002 14:03:46 GMT, Subject "Re: List 
slice assignment and custom sequences", message id 
<m2k7jsm7u7.fsf@python.net> .  The patch affects 
Objects/listobject.c: with no performance impact when the 
RHS of an assignment to a list slice is a list, the patch also 
allows the RHS to be any other sequence object acceptable 
to PySequence_Fast -- just like such general sequences are 
acceptable today e.g. as arguments to the extend method, 
so the patch makes them acceptable as RHS in assignment 
to list slices.



----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-11-05 12:12

Message:
Logged In: YES 
user_id=6380

The idea sounds like a fine one to me. (I think that's a
reversal of opinion. So be it. :-)

I don't want to be responsible for reviewing the code
however. Assigned to MWH (since there's no way to simply
unassign).

----------------------------------------------------------------------

Comment By: Alex Martelli (aleax)
Date: 2002-11-05 12:09

Message:
Logged In: YES 
user_id=60314

I cannot reliably measure any performance difference between 
using PySequence_Fast unconditionally, and specialcasing a list 
RHS.  I've attached the patch for the unconditional version, which 
is five lines less than the earlier specialcased version.


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-11-05 11:51

Message:
Logged In: YES 
user_id=6656

I wonder if you'd get much performance hit from just using
PySequence_FAST the whole time?  All that does for a list
after all is Py_INCREF it (I hope you still have whatever
test harness you used to make your claims in the description).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=633870&group_id=5470