Patches item #1617687, was opened at 2006-12-18 03:35
Message generated for change (Comment added) made by paulhankin
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1617687&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Thomas Wouters (twouters)
Assigned to: Nobody/Anonymous (nobody)
Summary: specialcase simple sliceobj in list (and bugfixes)
Initial Comment:
- Specialcase the step=1/None case of slicing using sliceobjects.
- Fix bug where slice insertion using a sliceobject was inserting in a
different place than slice inserting using a simple slice
- Fix two off-by-one bugs that were cancelling each other out: the non-step-1
slice deletion code was memmoving too much for each item to delete, and not
enough for the tail end, net result being a few too many bytes moved for each
item.
- Rewrite tail end move when deleting complex slice, use single memmove()
instead of repeated PyList_SET_ITEM()
- Expand comments describing the code somewhat.
----------------------------------------------------------------------
Comment By: Paul Hankin (paulhankin)
Date: 2007-03-11 16:25
Message:
Logged In: YES
user_id=1740099
Originator: NO
An alternative to the tail memmove would just be to incorporate it in the
main loop; something like (untested):
for(i=0; i<slicelength; i++){
size_t target = start + i * (step - 1);
size_t source = start + i * step + 1;
size_t source_end = i < slicelength - 1 ? source + step - 1
: self->ob_size;
garbage[i] = PyList_GET_ITEM(self, start + i * step);
assert(source_end <= self->ob_size);
memmove(&self->ob_item[target], &self->ob_item[source],
(source_end - source) * sizeof(PyObject *));
}
I think this also makes it more obvious what's going on - at the moment
the code smells a bit funny, even with your new comment.
Otherwise, the change looks good.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1617687&group_id=5470
_______________________________________________
Patches mailing list
[email protected]
http://mail.python.org/mailman/listinfo/patches