]> granicus.if.org Git - python/commit
Improve extended slicing support in builtin types and classes. Specifically:
authorThomas Wouters <thomas@python.org>
Tue, 28 Aug 2007 15:28:19 +0000 (15:28 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 28 Aug 2007 15:28:19 +0000 (15:28 +0000)
commit3ccec68a05abae43cf74dc7821c61ba88ab6cb46
tree07e97200d168eec13110e16a11b974310b8b550a
parent0f4a14b56fcbd939e60f424517db61ca6f2f3885
Improve extended slicing support in builtin types and classes. Specifically:

 - Specialcase extended slices that amount to a shallow copy the same way as
   is done for simple slices, in the tuple, string and unicode case.

 - Specialcase step-1 extended slices to optimize the common case for all
   involved types.

 - For lists, allow extended slice assignment of differing lengths as long
   as the step is 1. (Previously, 'l[:2:1] = []' failed even though
   'l[:2] = []' and 'l[:2:None] = []' do not.)

 - Implement extended slicing for buffer, array, structseq, mmap and
   UserString.UserString.

 - Implement slice-object support (but not non-step-1 slice assignment) for
   UserString.MutableString.

 - Add tests for all new functionality.
16 files changed:
Lib/UserString.py
Lib/test/list_tests.py
Lib/test/string_tests.py
Lib/test/test_array.py
Lib/test/test_buffer.py [new file with mode: 0644]
Lib/test/test_mmap.py
Lib/test/test_structseq.py
Lib/test/test_userstring.py
Modules/arraymodule.c
Modules/mmapmodule.c
Objects/bufferobject.c
Objects/listobject.c
Objects/stringobject.c
Objects/structseq.c
Objects/tupleobject.c
Objects/unicodeobject.c