16 votes

How Dropbox rolled out one of the largest Python 3 migrations ever

Tags: python

6 comments

  1. [6]
    unknown user
    Link
    As someone who basically never wrote more than three lines of Python in his life, is the 2-to-3 transition really this painful? The only difference I am aware of is UTF-8 support in Python 3,...

    As someone who basically never wrote more than three lines of Python in his life, is the 2-to-3 transition really this painful? The only difference I am aware of is UTF-8 support in Python 3, which, IMO, is more than enough motivation to do the switch, but apparently it's not that easy?

    2 votes
    1. [2]
      Deimos
      Link Parent
      I've never been part of a major migration myself, but I think that a lot of the issues probably come more from just updating/upgrading so much at once and uncertainty about whether anything is...
      • Exemplary

      I've never been part of a major migration myself, but I think that a lot of the issues probably come more from just updating/upgrading so much at once and uncertainty about whether anything is changing or breaking in unexpected ways. Large Python projects might depend on dozens or hundreds of other libraries, and to be able to upgrade the project itself you also need to upgrade all of those dependencies to Python 3 versions.

      If any of your dependencies don't have a Python 3 version, you either have to replace them with a different library or try porting them to Python 3 yourself, which might be very difficult depending on what they do (and you probably don't want to effectively have to take over maintenance of those libraries). This is a lot to worry about, especially if you don't have very comprehensive testing to be able to make sure that nothing subtle is being affected in the process.

      Overall, I think a lot of it is just that it's potentially a huge amount of work that might involve a lot of risk, and the benefits aren't necessarily very clear or compelling.

      8 votes
      1. Krael
        Link Parent
        Python 3 is almost ten years old now. While I really hate to blame developers, if your actively maintained codebase isn't compatible with it after having a decade to get your shit in order, that's...

        Python 3 is almost ten years old now. While I really hate to blame developers, if your actively maintained codebase isn't compatible with it after having a decade to get your shit in order, that's your fault.

        That doesn't apply to legacy software, of course. If you've got a reason to stick with Python 2, have at it.

        3 votes
    2. [4]
      Comment deleted by author
      Link Parent
      1. unknown user
        Link Parent
        That reminded me of a story that happened to me in college. A fellow student started learning Python, but his tutorial was for v2, while he had v3. He couldn't get print to work . I came to him...

        That reminded me of a story that happened to me in college. A fellow student started learning Python, but his tutorial was for v2, while he had v3. He couldn't get print to work . I came to him and added parentheses. It worked. He told me, "Dude, I've been trying to figure this out for an hour!". Good days.

        5 votes
      2. [2]
        arghdos
        Link Parent
        But, if you planned your code correctly it isn't so hard to support both. Between modules like future (essentially backports of 3 syntax / changes into 2), six (comparability goop for 2&3 codes)...

        But, if you planned your code correctly it isn't so hard to support both. Between modules like future (essentially backports of 3 syntax / changes into 2), six (comparability goop for 2&3 codes) and even brute force conversions like 2to3.

        For instance, you could write the following python2 code:

        from __future__ import print
        print(5)
        

        and you'll get "5" as an output (rather than "(5)" if you didn't use the future)

        The real trick is other peoples libraries, which you often have no control of.

        But considering Numpy is dropping support for 2.7 on 12/31/19, we're finally going to be able to start dropping 2.7 support!

        Now if I could only get fstrings backported to 3.0 :P

        5 votes
        1. [2]
          Comment deleted by author
          Link Parent
          1. arghdos
            (edited )
            Link Parent
            Very true. At one point in time I believe I saw a stat saying something like 50%+ of the top downloads on pypi supported 2.7 only... I wonder what that is today? Also, it could be worse... a...

            While you're right, if 3 was backwards compatible, other people's libraries would still work

            Very true. At one point in time I believe I saw a stat saying something like 50%+ of the top downloads on pypi supported 2.7 only... I wonder what that is today?

            Also, it could be worse... a package I use every day just dropped 2.6 support O.o

            edit: found it 349 of the top 360 packages on pypi support 3.X.

            1 vote