What about an EXPLICIT naming scheme for built-ins?

Jason Lai jmlai at uci.edu
Fri Sep 3 11:27:11 EDT 2004


Carlos Ribeiro wrote:
> On Sat, 4 Sep 2004 00:15:41 +1000, Andrew Durdin <adurdin at gmail.com> wrote:
> 
>>However, I think it'd be hard to make an iterator implementation of
>>sorted() without either copying the sequence or resorting to O(n^2)
>>performance, which is not good.
>>This may just be an example where inconsistency is a practical necessity.
> 
> 
> You may be right. At the least, this reasoning could possibly be
> included in the FAQ, as it will probably turn out to be a frequent
> question in the near future. But having sorted() to return a iterator
> still sounds like a logical thing to do, so I'm not sure about it.
> 

I had an idea for a moment about having sorted/reversed return the same 
type as it was passed -- so reversed(seq) returns a seq, 
reversed(iterator) returns an iterator. But it sounds confusing/magical 
and maybe out of line with Python philosophy. Although I think the whole 
iterator usage seems a little messy right now, so it's worth thinking 
about how seq/iterators-related functions should behave.

  - Jason Lai



More information about the Python-list mailing list