[C++-sig] vector_indexing_suite and slicing

Jonathan Brandmeyer jbrandmeyer at earthlink.net
Tue Mar 16 21:19:50 CET 2004


A few months ago there was a discussion on this list related to the
semantics of setting a (possibly extended) slice when the setting range
is empty[1].  As part of that discussion I submitted a patch to change
the behavior of a Python list [2].  The resolution on that was to
clarify that list.__setitem__(slice, obj)  has the following behavior
(no changes):

When called with a simple slice that defines an empty range, perform an
insertion at the first index.

When called with an extended slice regardless of the length of the
range, perform a replacement of the objects indexed by the slice with
objects from obj.  obj must have exactly the same number of elements as
indexed by the slice.

To close the loop, the attached patch will fix the bugs I noted in [3]
while following the guidance provided by the Python folks.  Unless there
are any objections, I'll commit this to HEAD and the RC_1_31_0 branch
tonight.

-Jonathan Brandmeyer


[1]: summary
http://mail.python.org/pipermail/c++-sig/2004-January/006589.html
[2]: bug tracker for python
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=873305&group_id=5470
[3]: http://mail.python.org/pipermail/c++-sig/2004-January/006552.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: indexing_suite.patch
Type: text/x-patch
Size: 4288 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040316/93cad8ac/attachment.bin>


More information about the Cplusplus-sig mailing list