This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients alex, brett.cannon, gregory.p.smith, santoso.wijaya, serhiy.storchaka, terry.reedy, tshepang
Date 2013-03-09.02:02:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1362794578.37.0.544586168747.issue17343@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-03-09 02:02:58terry.reedysetrecipients: + terry.reedy, brett.cannon, gregory.p.smith, alex, santoso.wijaya, tshepang, serhiy.storchaka
2013-03-09 02:02:58terry.reedysetmessageid: <1362794578.37.0.544586168747.issue17343@psf.upfronthosting.co.za>
2013-03-09 02:02:58terry.reedylinkissue17343 messages
2013-03-09 02:02:57terry.reedycreate