list.sort, was Re: [Python-Dev] decorate-sort-undecorate
Raymond Hettinger
python at rcn.com
Tue Oct 28 00:11:08 EST 2003
More information about the Python-Dev mailing list
Tue Oct 28 00:11:08 EST 2003
- Previous message: list.sort, was Re: [Python-Dev] decorate-sort-undecorate
- Next message: list.sort, was Re: [Python-Dev] decorate-sort-undecorate
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Bob Ippolito] > How about making islice be more lenient about inputs? For example > x[::-1] should be expressable by islice(x, None, None, -1) when the > input implements __len__ and __getitem__ -- but it's not. [::-1] > *does* create a temporary list, because Python doesn't have "views" of > lists/tuples. islice should also let you go backwards in general, > islice(x, len(x)-1, None, -2) should work. Sorry, this idea was examined and rejected long ago. The itertools principles involved are: - avoiding calls that cause the whole stream to be realized, - avoiding situations that require much of the data to be stored in memory, - an itertool should work well with other tools and handle all kinds of iterators as inputs. islice(it, None, None, -1) is a disaster when presented with an infinite iterator and a near disaster with a long running iterator. Handling negative steps entails saving data in memory. The issue of reverse iteration is being dealt with outside the scope of itertools. See the soon to be revised PEP 322 on reverse iteration. It will give you the "views" that you seek :-) Raymond Hettinger
- Previous message: list.sort, was Re: [Python-Dev] decorate-sort-undecorate
- Next message: list.sort, was Re: [Python-Dev] decorate-sort-undecorate
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list