How we retired Python 2 and improved developer happiness

Barry Warsaw
7 min readbeginner
--
View Original

Overview

The article discusses LinkedIn's transition from Python 2 to Python 3, emphasizing the importance of this migration for improving developer happiness and productivity. It details the planning, execution phases, and the benefits of adopting Python 3, including enhanced features and reduced support burdens.

What You'll Learn

1

How to transition from Python 2 to Python 3 in a large codebase

2

Why adopting a bilingual library approach facilitates smoother migrations

3

How to identify foundational repositories that block migration efforts

4

When to invest in tests and code coverage during migration

Prerequisites & Requirements

  • Understanding of Python programming and its version differences
  • Experience with managing code repositories and dependencies(optional)

Key Questions Answered

What were the phases of LinkedIn's migration from Python 2 to Python 3?
LinkedIn's migration was divided into two phases. Phase 1 focused on identifying foundational repositories that needed to be ported first, which included about 75 repositories. Phase 2 involved porting the remaining repositories and any carryovers from Phase 1, ensuring a comprehensive transition to Python 3.
What benefits does Python 3 provide over Python 2?
Python 3 offers faster performance, greater consistency, and new features such as asyncio and type hinting. These improvements enhance developer productivity and reduce the likelihood of errors, particularly with data types and Unicode handling, which were problematic in Python 2.
How did LinkedIn ensure a smooth migration process?
LinkedIn's migration was overseen by the Horizontal Initiatives program, with the Python Foundation team coordinating efforts across various departments. They engaged with developers, created work tickets, and tracked deadlines to facilitate the transition, ensuring all 550 repositories were addressed within the planned timeframe.
What challenges did LinkedIn face during the migration?
Challenges included dealing with low test coverage in some codebases, which affected confidence in the fidelity of the port. Ensuring that all repositories built successfully and passed unit and integration tests was crucial for validating the migration.

Key Statistics & Figures

Number of code repositories migrated
550
This number reflects the total repositories that needed to be ported during LinkedIn's transition from Python 2 to Python 3.
Duration of the migration effort
2 quarters
The migration was planned and executed over two quarters, ensuring a structured approach to phasing out Python 2.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Engage Python experts early in the migration process to leverage their knowledge and support.
Involving experts helps promote the benefits of Python 3 and ensures that the migration is well-planned and executed, reducing potential roadblocks.
2
Adopt a bilingual library approach to ease the transition for library consumers.
This strategy allows teams to port to Python 3 at their convenience, minimizing disruption while still supporting Python 2 during the transition period.
3
Invest in comprehensive testing and code coverage to validate migration success.
High test coverage provides confidence that the migrated code behaves as expected, which is essential for maintaining quality during and after the transition.

Common Pitfalls

1
Failing to adequately test low coverage codebases during migration can lead to undetected issues.
Low test coverage means that potential bugs may not be caught during the migration process, leading to problems in production. It's crucial to prioritize testing and increase coverage before migration.

Related Concepts

Python 3 Features
Bilingual Library Approach
Code Repository Management
Dependency Management