[Python-Dev] Python 3 design principles
Jim Jewett
jimjjewett at gmail.com
Fri Sep 2 01:44:02 CEST 2005
Nick Craig-Wood wrote:
> If come python 3, there is a 99% accurate program which can turn your
> python 2.x into python 3 code, then that would ease the transition
> greatly.
Guido wrote:
> That might not be so easy given the desire to change most
> list-returning functions and methods into iterator-returning ones.
I assume part of the cleanup will include adding a choke point
for import hooks. That way people could do the conversion
on modules that they aren't sure about. There would be a
performance penalty, but things would still work, and could be
sped up as it was justified.
> This means that *most* places where you use keys() your code will
> still run, but *some* places you'll have to write list(d.keys()). How
> is the translator going to know?
So do it everywhere, in the auto-import.
> Worse, there's a common idiom:
> L = D.keys()
> L.sort()
> that should be replaced by
> L = sorted(D)
L = list(D.keys())
L = sorted(L)
Not as efficient. Not as pretty. With work, even a
mechanical importer could do better. But the old
code would still run correctly.
-jJ
More information about the Python-Dev
mailing list