Python Version History: How Python has changed over the years
Tags: python, programming
Published: 2023-02-17 18:42:17

One of the 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 the 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.11 and examine the steps that fueled Python's rise to prominence. 
 
**Here’s what we’ll cover today:**
 
* [Why was Python made?](#why)
* [Python 1](#version1)
* [Python 2](#version2)
* [Python 3](#version3)
* [What's the future of Python?](#future)

![Python history](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ogkuhp6rsay4zspm9zt7.png)

<br>
 
<a name="why"></a>
 
## 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.

![Python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gexpckgdsd82hu66159m.png)

<br>
 
<a name="version1"></a>
 
## Python 1

Python 1 launched in 1994 with new features for functional programming, including [lambda](https://www.educative.io/blog/python-lambda-functions-tutorial?eid=5082902844932096), 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 a 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.

<a name="version2"></a>
 
## 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.

<br>

### 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:

```py
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 encode it as `UTF-8`:

```py
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:

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

<br>

### List Comprehension

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

The syntax for list comprehensions is: 
```py
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.

```py
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]
```
<br>

### 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.

<br>

### 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. 

![Python 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmdja4kio75fb5802g5n.png)


![Python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6y0x1veuk4clcckj9g2n.png)


<a name="version3"></a>
 
## 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](https://www.educative.io/blog/r-tutorial-beginners-guide?eid=5082902844932096) 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](https://www.educative.io/blog/python-pandas-tutorial?eid=5082902844932096), [Scikit-learn](https://www.educative.io/blog/scikit-learn-tutorial-linear-regression?eid=5082902844932096), 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. 

<br>

### 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.


<br>

### `Print` Function

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:

```py
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.
 
```py
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.

```Py
##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 straightforward that you can automatically convert all old print statements to functions using the `2to3` tool. 

<bR>

### `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())`. 

<br>

### 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()`:

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

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

<br>

### 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. 

<br>
 
### Major changes of each Python 3 Version

![Python 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkncg9ujkztmeajwvag5.png)

<br>
 
<a name="future"></a>
 
## 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 into 2023 and beyond with new versions [3.10](https://www.python.org/downloads/release/python-3100/) (2021) and [3.11](https://www.python.org/downloads/) (2022), which spiked a surge in AI, automation technologies, and data science tracking. 

The growth spike is expected to stick around in the following years, 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.
 
<br>
 
### Continue reading about Python on Educative
* [Python 3.9 Updates: topographical sort and string manipulation](https://www.educative.io/blog/python-update-topographical-sort?eid=5082902844932096)
* [10 Python quirks you should know about in your code](https://www.educative.io/blog/python-quirks-tricks?eid=5082902844932096)
* [50 Python Interview Questions and Answers](https://www.educative.io/blog/python-interview-questions?eid=5082902844932096)

### Start a discussion
What updates do you hope to see from Python in the future? Was this article helpful? Let us know in the comments below!