[Python-3000] Removing 'old-style' ('simple') slices from Py3K. (original) (raw)

Thomas Wouters thomas at python.org
Fri Aug 25 02:46:08 CEST 2006


I spent my time at the Google sprint working on removing simple slices from Py3k, in the p3yk-noslice branch. The work is pretty much done, except for some minor details and finishing touches. There are a few items that should probably be discussed, though.

The state of the tree:

I think the extended-slicing support as well as the simpleslice specialcasing should be ported to 2.6. Are there any objections to that? It means, in some cases, a bit of code duplication, but it would make 's[::]' almost as fast as 's[:]' for those types.

I also think it may be worthwhile to switch to always using slice objects in Python 2.6 or 2.7. It would mean we can remove the 12 bytecodes for slicing, plus the associated code in the main bytecode loop. We can still call sq_slice/sq_ass_slice if step is None. The main issue is that it might be a net slowdown for slicing (but speedup for all other operations), and that it is no longer possible to see the difference between obj[:] and obj[::]. I personally think code that treats those two (significantly) differently is insane.

Now that all those types have mp_subscript defined, we could remove sq_item and sq_ass_item as well. I'm not entirely sure I see all the implications of that, though. The C code does quite a lot of indexing of tuples and lists, and those are indexed using Py_ssize_t's directly. Going through a PyObject for that may be too cumbersome.

-- Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-3000/attachments/20060824/c60c127a/attachment.htm



More information about the Python-3000 mailing list