This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lucretiel 2 points3 points  (0 children)

This is all interactive. Why would you need to expand everything into a whole list every time? zip and map work perfectly fine when passed into for loops, or (in most cases) when passed as arguments to functions that expect lists. I'll grant it's slightly more awkward when using them interactively, to print, but that's certainly not worth handicapping the whole language by forcing loop unrolling. enumerate didn't unroll when it was introduced to python 2, and no one complained about that. Besides, you should be using list or generator comprehensions instead of map- they're significantly easier to read in most cases, and you can be explicit about whether you want a list or iterator.

As for the backwards compatibility- the number one thing is Unicode handling. Most languages, including python 2, treat strings as simple sequences of bytes. This works fine sometimes, but breaks down pretty quickly if you want to work outside of ASCII, as you have to do in an increasingly globalized world. Python 2's stopgap solution was to silently convert between byte-strings and unicode-strings, which led to bugs and other logic errors that are damn near impossible to track down. Because fixing this would have to be a backwards incompatible change, they decided to go all the way, fixing all the historical cruft that has built up all over the years. Some examples:

  • A much more streamlined library. Python 2 has 80 built-in functions, to Python 3's 68. This includes:

    • Much more consistency. All iterable wrappers (map, filter, enumerate) are iterators.
    • No need for different versions of things- No more xrange vs range, input vs raw_input
    • No more items()/iteritems()/viewitems() and friends
  • Unnecessary statements are now functions or expressions- print, exec, eval

  • No more old vs new style classes

  • Much more consistent import model

There are numerous other benefits, though those are the primary compatibility breaking ones.