Terry J. Reedy added the comment:

I personally would have changed both str.split and os.walk to return iterators 
in 3.0, like many other builtins. The rationale for os.walk continuing to 
produce a list is that there would be little time saving as the list is not 
*that* long and most uses look at all the items anyway. (See tracker issue.) 
This argument might be even stronger for str.split.

When I expressed my view about str.split (after 3.0, I think), Guido said that 
if people do not look at all the items, they typically need random access, and 
hence a list anyway, so why make them write list(xxx.split()) all the time?

I will also note that Guido has opposed string views and partial object views 
in general on the basis that a tiny view can keep a mega object alive, and that 
it is too much to ask people to keep track of when they should copy the view to 
release the underlying object.

Iterators also (should) keep the underlying object alive, but they are usually 
short-lived and not passed around hither and thither.

I personally would prefer that the API for this proposal simply be a new 
parameter (iter(able)=False/True). But that runs into 'argument values should 
not change the return type' (but lists and iterators are *both iterables*!). 
Instead there supposedly should be a new, almost identical function with a new, 
almost identical name. But that runs into 'we should not add builtins with a 
really good reason' (which I agree with) and more directly 'we should not 
repeat the confusing range/xrange mess' (which I also agree with). So the 
status quo is a Catch 22 situation with conflicting principles that produce 
paralysis. As I said, I prefer redefining the return as an iterable.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17343>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to