[Python-Dev] Python3: speed efficiency vs user friendliness (my first experience)

Steven D'Aprano steve at pearwood.info
Wed Mar 23 13:01:40 CET 2011


Lennart Regebro wrote:
> On Tue, Mar 22, 2011 at 22:12, Steven D'Aprano <steve at pearwood.info> wrote:
>> The main one that comes to my mind is that other than looping, any time I
>> want to process dict.items() etc I often need to call list() first.
> 
> "Process" no. If you want it to be a list, yes. This is because they
> now return generators, which is a massive improvement.

Well, yes, that's what I meant when I said other than looping. (I'm 
aware that there are uses for lazy iterators other than for-loops.)

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.

To be clear, I'm *not* objecting to this state of affairs. I think the 
trade-off in this case is the right thing to do. But Anatoly seems to 
think that Python3 has generally made the wrong trade-off, and I was 
hoping he would mention some other concrete examples.


For the record, this next double-quoted >> statement is not by me. It 
was actually from Anatoly Techtonik:

>> but what I really
>> didn't expect is to see that choice is made not in user's favor, but
>> in a favor of speed.
> 
> I'm not sure what choice you are talking of here... And in this case
> Python 2 behaved differently on different platforms and Python 3
> doesn't. That seems to be an improvement to me...


Lennart, please be a little more careful with your attributions.




-- 
Steven


More information about the Python-Dev mailing list