[pypy-dev] range list implementation
Lenard Lindstrom
len-l at telus.net
Sun Oct 22 01:43:57 CEST 2006
On 21 Oct 2006 at 23:52, Carl Friedrich Bolz wrote:
> Hi all!
>
> Just a few words about the range list implementation I wrote during the
> last few days (when I was fed up with the config branch...). There is a
> new list implementation W_RangeListObject. The idea is that calling
> range will not immediately allocate the whole list but only store start,
> stop and step into the range list object. The range list object behaves
> like a perfectly normal list to the user. For some operations the range
> list is 'forced', that is the full list is generated. This is especially
> the case for operations that mutate the list. The following operations
> on the range list keep it in its non-forced memory-saving form:
>
> * iteration
> * len
> * getitem
> * getitem with a slice (which returns a new range list)
> * iter
> * repr
> * reverse
> * sort
>
Early versions of the xrange type supported slicing. Slicing was dropped from
xrange in Python 2.2. As I recall reading somewhere there just wasn't enough
interest to justify the cost of maintaining the C code. But maybe it makes more
sense when coded in Python.
Lenard Lindstrom
<len-l at telus.net>
More information about the Pypy-dev
mailing list