Home/Blog/Programming/Python Version History: How Python has changed over the years
Home/Blog/Programming/Python Version History: How Python has changed over the years

Python Version History: How Python has changed over the years

Ryan Thelin
Nov 14, 2023
12 min read

Become a Software Engineer in Months, Not Years

From your first line of code, to your first day on the job — Educative has you covered. Join 2M+ developers learning in-demand programming skills.

One of those most popular languages in the world, Python has gone through many iterations to match the changing needs of developers and technology trends.

What started as one man’s side project has now advanced to be the fastest growing language in the world. Python is now tool of choice for the next generation of data-driven and AI solutions.

Today, we’ll look at the changes in the different versions of Python from prelaunch to 3.9 and examine the steps that fueled Python’s rise to prominence.

Master Python in half the time

Become a Python Developer the fast way with hands-on, text-based lessons.

Ace the Python Coding Interview

Why was Python made?#

Python was made by Dutch programmer Guido Van Rossum in the late 1980s. At the time, he was working on a distributed system called Amoeba at CWI, a computer science research center in the Netherlands. C was the primary language he and the other researchers used.

Van Rossum felt that programming with C was **too time consuming*8. He began to create a new language in his free time that would let him work faster. Little did he know that this side project would eventually become one of the most popular, widespread programming languages in the world.

The appeal of Python has always been its simplicity and unique mixture of C with bash script capabilities. Van Rossum drew heavily on the ABC programming language but included tools for dynamic types and imperative programming as well.

History: As Van Rossum was creating Python, he was reading the script of a popular BBC comedy series called “Monty Python’s Flying Circus”. So he decided on the name Python for his new language because it was unique and mysterious.

Python began to slowly rise in popularity after its open-source release on alt.sources. By the 1990s, Python started to win out over other similar languages like Perl and Ruby due to support by tech companies NIST and Microsoft.

The primary benefits of any Python version are:

  • Readability, English-like syntax lets you parse meaning at a glance.
  • Interpreted Language, easier to debug.
  • Dynamically Typed, Python determines types at execution. No need to declare variables and data types.
  • Open-Source, Python is free to use and develops quickly due to community input.

Overall, Python is designed to do more work on its own than most languages to allow the developer to focus on their work.

Original Python Logo

Python 1#

Python 1 launched in 1994 with new features for functional programming, including lambda, map, filter and reduce. It also included features from 0.9 Python, including classes with inheritance, exception handling, functions, and the core data types list, dict, str.

Python 1.4 brought its next set of features, such as Modula-3 style keyword arguments and support for complex number operations.

Other version 1 updates included optimizations, background changes, and updates to documentation/licences.

During this period, Perl was the most popular scripting language, and Python was too immature to be used at wide scale. As more developers sought alternatives to Perl, Python seemed the best choice, as it mimics many of Perl’s features. In the world of object-oriented programming, Java was on the rise during this era of Visual Basic and C/C++.

This marked a shift to adopt languages other than C/C++ and opened the door for Python to grow.

Python 2#

Python 2 launched in 2000 with big changes to source code storage. It introduced many desired features like unicode support, list comprehension, and garbage collection. A bit later, Python 2.2 introduced unification of types and classes under one hierarchy, allowing Python to be truly object-oriented.

Around this time, many programmers used to adopt Python as an alternate scripting language. Since Java was dominating in the world of enterprise-sized applications, Python was used in smaller, niche applications.

Even Java developers started using Python to increase their coding speed due to its interoperability.

Unicode#

Python 2.0 introduced the Unicode string data type that allocated 16bit numbers to represent characters instead of standard 8bit strings. This adds 65,000 additional supported symbols from non-latin script languages like Russian, Chinese, or Arabic. It also added support for non-letter characters like emojis.

The syntax for Unicode strings is:

u`unicode string` 

You can also use unicode to encode your own strings to a unique designation. Calling that unique designation later in your code allows you to reference that same encoded string without using additional space or saving it in a variable.

The following writes a unicode string to file and encodes it as UTF-8:

import codecs

unistr = u'\u0660\u2000ab ...'

(UTF8_encode, UTF8_decode,
 UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8')

output = UTF8_streamwriter( open( '/tmp/output', 'wb') )
output.write( unistr )
output.close()

Then, you can read that encoded file later using:

input = UTF8_streamreader( open( '/tmp/output', 'rb') )
print repr(input.read())
input.close()

List Comprehension#

List comprehensions are used to create new lists from from other iterables. List comprehensions take and return a list, allowing you to trim a list by a certain criteria or to create a new list with newly manipulated elements.

The syntax for list comprehensions is:

new_list = [expression for_loop_one_or_more conditions]

The following shows how you can use list comprehensions to return a new list with only elements that are present in both passed lists.

list_a = [1, 2, 3, 4]
list_b = [2, 3, 4, 5]

common_num = [a for a in list_a for b in list_b if a == b]

print(common_num) # Output: [2, 3, 4]

Garbage collection cycles#

Python 2.0 overhauls the garbage collection system by switching from a counter-based system to a cycle-based system.

In the old system, each object would contain a counter that records how many other objects are pointing to it. The object was then automatically deleted once that counter reached zero. However, it wouldn’t delete objects that were pointed to but were not accessible, resulting n a memory leak.

Python 2.0 fixes this by periodic cycles that call the garbage collector to delete inaccessible objects. The cycles use additional overhead but reduce the risk of a memory leak. Overhead costs of the deletion cycles have since been reduced due to optimizations.

Enjoying the article? Scroll down to sign up for our free, bi-monthly newsletter.

Augmented Assignment#

Python 2.0 also adds support for augmented assignment operators that perform an operation on the chosen variable and return the variable. For example, a += 1 adds 1 to the value of a. It is a shorter version of the statement = a + 1.

The full list of supported assignment operators is +=, -=, *=, /=, %=, **=, &=, |=, ^=, >>=, and <<=.

These operators are especially useful when used in conjunction with looping structures.

Version: Release Date: Major Changes:
Python 2.1 October 2001 Added support for nested scopes to perform more like other statically scoped languages
Python 2.2 December 2001 Unified types and classes into one Python hierarchy to make Python more object-oriented. Also, added generator routines that control the behavior of loops.
Python 2.4 March 2005 Added generator expressions for iterator feature, function decorators, and the decimal data type
Python 2.5 September 2006 Added the with statement that encloses code within a context manager.
Python 2.6 October 2006 Added all backwards compatible 3.0 features, including typeError, bin(), and _complex_(). Switched from SourceForge Issue Tracking to Roundup. Also, optimized the with statement.
Python 2.7 June 2009 - Minor bug fixes and optimizations. Terminated support for Python 2.

Keep learning about Python#

Practice cutting-edge Python techniques as you prepare for your coding interview. Educative’s Learning Paths let you access all our best content and practice problems from across our entire course library.

Ace the Python Coding Interview


Modern Python Logo

Python 3#

Python 3.0 is the biggest change the language has undergone. The main mission of the update was to remove fundamental design flaws with the language by deleting duplicate modules and constructs.

Python 3’s development was steered by the same philosophies as previous versions but also added that for every task “there should be one— and preferably only one —obvious way to do it”.

Removing many duplicate tools unfortunately meant that all previous Python 2 code was not compatible with Python 3.0. Some of the most notable changes are that print is now a built-in function, removal of the Python 2 input, unification of str and unicode, and changes in integer division.

Thankfully, the team at Python created a tool called 2to3 that will review an old Python 2 program and convert much of the changed syntax to Python 3 automatically.

The release of Python 3.0 pushed it into the developer limelight, and it attracted the scientific community, particularly in fields like neuroscience. Once the NumPy library was created in Python, Python became a competitor with R and Matlab, pushing Python into its pedestal as the preferred language for machine learning and data science.

With the rise of big data in the early 2000s, spurred by the 2008 financial crisis, a new need for data automation tools spiked. Many companies adopted Python for its simplicity and powerful libraries. Shortly after, it became the preferred language for managing social-media data.

It was around this time that Pandas, Scikit-learn, and Matplotlib were developed to meet this demand.

Between 2012 and 2015, large technology companies like Facebook, Google, and Netflix soon expanded the field of data science and machine learning, using Python as the primary language and R for data visualization. More big-name Python tools like TensorFlow and Seaborn were developed by these companies, making Python the #1 choice for data scientists.

Note: Around 2014, Python had become one of the primary programming languages for beginners. It was even adopted by universities for CS student students and coding camps around the world.

Minor changes in Python 3.0#

  • reduce(): reduce() has been moved from builtins into functools. However map() and filter() remain built-in.
  • Old feature removal: old-style classes, string exceptions, and implicit relative imports are no longer supported.
  • Exception handling: exceptions now need the as keyword, exec as *var* is standard over exec, *var*.
  • with statement: with is now built in and no longer needs to be imported from __future__.
  • range: xrange() from Python 2 has been replaced by range(). The original range() behavior is no longer available.

In Python 2, print was a statement that had to be imported from __future__. In Python 3, it has been changed to a built-in function and no longer requires any imports. As it is now a function, you must have all printed arguments enclosed in parentheses, print("printed").

For example:

Old: print "The answer is", 2*2
New: print("The answer is", 2*2)

One notable side effect of this is that you can no longer use an empty print statement to create a new line.

Old: print              # Prints a newline
New: print()            # You must call the function!

Further, the print() function does not support the “softspace” feature that internally tracks the state of phrases printed together. In Python 3, two printed phrases will automatically be parsed by a space.

##Py2
print "A\n", "B" 
"A\nB\n"

##Py3
print("A\n", "B")
"A\n B\n"

Apart from these slight changes, the new print() performs identically. These changes are so straight forward that you can automatically convert all old print statements to functions using the 2to3 tool.

raw_input to input#

The Python 2.0 version of input has been removed and the old raw_input has been renamed to input. This means that input now always returns as a string rather than being evaluated as an expression.

The goal of the change is to remove confusion around the behavior of the two similar inputs and instead favor the more common use. If you want to use the old functionality, you can instead use eval(input()).

Unification of str and Unicode#

In Python 3, all text content such as strings are Unicode by default. The goal here was to reduce errors caused by mixing encoded and unicode data types in the same program.

You can instead encode strings to bytes using the new immutable bytes type created with the bytes() method. There is also a mutable version created using the bytearray() method.

The bytes() method takes three optional parameters:

  • source: source to initialize the array of bytes.
  • encoding: if the source is a string, the encoding of the string.
  • errors: if the source is a string, the action to take when the encoding conversion fails

The advantage of using bytes is that they hold different forms of data while unicode can only represent text-like data.

For example, you could convert an entire list to bytes using bytes():

rList = [1, 2, 3, 4, 5]

arr = bytes(rList)
print(arr)
//Output: b'\x01\x02\x03\x04\x05'

Integer division#

In Python 3, division operations that result in decimals return a float rather than a truncated integer.

In Python 2, the outcome of 5/2 would be 2 because the decimal is automatically truncated to form an integer. Now, 5/2 equals 2.5 where the outcome is converted to a float to represent the correct answer. You can still get the truncating behavior if you use the // operator, 5//2.

The desire here is to remove unexpected behavior from unintentional truncation.

Version

Release Date

Major Changes

Python 3.1

June 2009

Added support for ordered dictionaries, which let configuration files be read, modified, and then written back in their original order.

Python 3.2

February 2011

Adds the option to restrict modules to specific APIs that will remain stable despite updates. Added the argparse module to replace optparse and the futures library for concurrent programming.

Python 3.3

September 2012

Added yield from expression for generator delegation. Readded explicit unicode declaration support to ease transition from Py2 to Py3. Simplified error catching by removing the requirement to name a specific error type. All errors can now be caught using OSError.

Python 3.4

March 2014

Added the asyncho module that includes support for event loop implementations.

Python 3.5

September 2015

Additional support for asynchronous programming by adding awaitable objects, coroutine functions, asynchronous iteration, and asynchronous context managers.

Python 3.6

December 2016

Stabilized asyncho module with additional features, syntax, optimizations, and bug fixes. Added support for asynchronous generators and compressions. Added f-strings, which include expressions evaluated at runtime.

Python 3.7

June 2018

Added async and await as reserved keywords. Also, added breakpoint() method, which drops you into the debugger at the call site. Annotation evaluations can now be postponed until runtime rather than at definition to avoid scope errors.

Python 3.8

October 2019

Added “walrus operator” (:=) that allows you to assign value to variables as part of a larger expression. Enabled positional-only arguments that allows you to specify that a parameter must be noted by position rather than keyword. Added support for f-string specifier = to allow more control over how the f-string is presented.

Python 3.9

October 2020

Merge (|) and update (|=) added to dict library to complement dict.update() method. Added str.removeprefix(prefix) and str.removesuffix(suffix) to easily remove unneeded sections of a string.

Python 3.10

October 2021

Python 3.10 introduced structural pattern matching with the match statement, providing a functionality akin to the switch or case statements found in other languages. Another significant enhancement of this update was the ability to use multiple context managers in a single statement through parenthesized context managers.

Python 3.11

October 2022

This major update undoubtedly appealed to data scientists by enhancing speed. Compared to 3.10, the standard benchmark suite operated roughly 25% quicker. In certain cases, according to the Python documentation, 3.11 could achieve speeds up to 60% faster.

Python 3.12

October 2023

This update introduced improved error messages. Several error messages now come with helpful suggestions. This update also optimized garbage collection and object traversal, leading to better overall memory management.

For a printable Python 3 cheatsheet, see our Python 3 Guide

What’s the future of Python#

In 2019, Python was declared as the fastest-growing programming language in the world, and it now has one of the largest programming communities. This growth is expected to continue following the 2020 lockdowns, which spiked a surge in AI, automation technologies, and data science tracking.

The growth spike is expected to stick around after the COVID-19 pandemic, with more businesses than ever before realizing the benefits of AI and data science. The recurrent sentiment is that businesses cannot risk making a wrong business decision in these fragile times.

This naturally leads many to invest heavily in data science predictive analytics, even in non-tech sectors like tourism, real estate, health care, and more.

While other languages like Rust and TypeScript are trying to capitalize, Python is already well established and proven in these fields. Python is perfectly positioned to grow along with this historic uptick in data-driven innovations.

With more visualization and data analytics tools being released with each version, it seems like Python won’t give up its lead anytime soon.

Continue reading about Python#


  

Free Resources