Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

[copying comment from an older HN thread, not speaking on behalf of any employer, opinions my own]

I think many people underestimate the challenge that the 2 to 3 migration presents for large enterprises. The core issue is that even though the migration for any given module is normally really easy, the total effort required to migrate is still essentially O(n) in module count/file count, because even with current tooling you still need to have an engineer look at every module to do the change safely. Even if it only takes ~5 minutes per module to make the changes and validate that it works correctly, this becomes a giant undertaking when you have tens of thousands of files to migrate.

The fact that it takes a long time also creates other problems. Your business isn't going to hit "pause" on other development, so there will be changes constantly introduced into modules you've already "swept". It's going to be hard to make sure 100% of your engineers and code reviewers are knowledgeable about the specific requirements to make sure the code works in both 2 and 3, so you would really like some automated safeguards to make sure they don't introduce anything that won't work in 3. Pylint helps with this, but won't catch everything. Unit tests are obviously essential, but:

1. Even a well-tested project won't have tests that cover 100% of code paths and behavior.

2. You're stuck running the tests on both python2 and python3 for the duration of the migration, which doubles the resource (compute, memory, etc.) cost of your Python CI and regression testing infrastructure for the duration of the migration.

Most big companies have passionate Python advocates who really want to be on Python 3, but the scale of the problem and the lack of tooling to tackle it with a sub-O(n) amount of effort make the overall project risky and expensive for the business.



As a member of a team hopefully nearing the end of the python3 migration, this is exactly correct.

The unicode switch is a nightmare in terms of having to go through and double/triple check everything and still get it wrong half the time. Particularly when it comes to moving data over the network.

The big selling point for Python3 finally came with the built-in async support, but we've been using Twisted for a decade, which works nearly identically, so even that wasn't a huge draw for us.

Further, many of our dependencies were python2-only up until the last year or two.

Really the only reason we're going through the effort right now is that Python2 is rapidly approaching End of life.


right - and .. for the one that posted on YNews to say "yes we did it" there are of course others who do not post on YNews and did not do it.. There is nothing wrong or bad about Python 2.7, in fact, its great and works as advertised.


> works as advertised

That's kind of a low bar. An IBM PC running MS-DOS 3.3 works as advertised but I wouldn't want to use one today. Except for the keyboard.


The way to start a migration is to first get the 2.7 code as forward compatible as possible. Bring in the future imports. Make sure equivalent iterators are used where 3.x mandates them (xrange, iterkeys, etc.). Make sure Unicode is managed correctly on I/O. Explicitly call out truncating division.

This doesn't require parallel testing. These all improve the quality of 2.x code even if you never make the leap to 3.x.

Once this is done you can use 2to3 to mechanically fix the remaining differences. Anything else that remains broken can be special-cased in the 2.7 code until 2to3 works without intervention.


2to3 never worked and will never work "without intervention".

That's why six and manual changes are always needed...


Using six is intervention. You end up with code that has one foot stuck in the past.


It requires parallel testing to make sure the files you've "future-proofed" aren't accidentally un-future-proofed by later commits.


Please link to previous comments rather than copying them. Copy/paste isn't good for fresh conversation: https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...

It's a great comment otherwise.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: