The Python language does not generally provide backward compatibility. The ability to break inefficiencies and fix wrong design choices are major reasons why Python has remained lean and efficient over the last decades. However, the PEP 387 standard discusses that incompatibility issues should be well thought out.
Here’s the basic policy when backward incompatibilities may be introduced for the benefit of the programming language’s effectiveness:
- The change should have a large benefit to breakage ratio, i.e., a relatively high benefit and a low probability of breaking old code.
- The change that leads to incompatiblity should be easy to fix.
- The change should not lead to a semantic change of a given API because those type of changes are extremely hard to find.
- An exception to the previous rule is if one goes over a two-year depreciation period.
These rules are not 100% fixed—for example, the steering council can grant exceptions to those.
Here are two quotes regarding Python’s policy to backward compatibility:
“To remain relevant and useful, Python has to evolve frequently; some enhancements require incompatible changes.” — Victor Stinner
“I don’t believe that the way for Python to remain relevant and useful for the next 10 years is to cease all language evolution. Who knows what the computing landscape will look like in 5 years, let alone 10? Something as arbitrary as a 10-year moratorium is (again, IMHO) a death sentence for the language.” — Barry Warsaw
In summary: the policy for Python version backward compatibility is that it should be avoided if possible but is not guaranteed.
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He’s author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.