On Wed, Mar 23, 2011 at 13:01, Steven D'Aprano <st...@pearwood.info> wrote: > But the improvement is exactly what Anatoly is talking about: it's an > improvement in speed over user convenience. If all you are doing is > iterating over a moderately-sized dictionary, you probably don't care > whether items() etc. returns a list or an iterator. But if you want to take > those items away and do something with them, you need a list, and that's > ever-so-slightly less convenient now than it was.
But how often are you doing things with the results from items() and values() that doesn't involve iterating over them? Sure, you can take a slice, but there is no point in slicing a list that comes from a dictionary because it's not ordered, so you won't know which item you get. You could sort them of course, but sorted() takes an iterable and returns a list anyway. And in what way is it more convenient to default to what you usually don't want? In most cases you do *not* want a list. So now, you in most cases do not get a list. Before, if you didn't want a lite you used d.iteritems(). Now if you want a list you use list(d.items()). So I don't agree that this is speed over convenience. It's speed *and* convenience. Python 3 is *more* convenient here, because the most common usecases are the most convenient. In Python 2 it was the other way around. It just feels inconvenient because we were used to it being the other way around. > Lennart, please be a little more careful with your attributions. Sorry! //Lennart _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com