From: Michael H. <hag...@jp...> - 2005-04-19 08:44:40
|
Frank Wierzbicki wrote: > I'm working on implementing some Python 2.3 list behaviors in PyList > and I've come to deleting a slice with a step value greater than one. > Thinking about the problem, it will be a little annoying to do this by > creating a new array and copying the diffed array in (this is > essentially how the slice deleting works now). It occurred to me that > this would be *much* easier to implement if PyList was backed by an > ArrayList (just remove() the elements). In fact much of PyList would > become simpler, at least with respect to readability and > maintainability. Does anyone have any objections to replacing the > internal array in PyList with an ArrayList, especially given that we > are dropping Java 1.1 support? I don't have anything against backing PyList with ArrayList, but you should definitely not use remove() to delete a slice. ArrayList would have to make a copy for every deleted element, making it an order n*m operation (n = length of array, m = length of slice) instead of linear in n, as is the copying version. Michael -- Michael Haggerty JPK Instruments hag...@jp... |