Almost 15 years after the release of Python 3 many people are wondering when Python 4 might be coming out. During the release of Python 3, there were some compatibility issues. Especially dependencies of many Python 2 applications weren’t updated quickly (or at all) introducing  significant challenges for switching to Python 3 for many companies and developers.

Fast forward to 2022, we are enjoying a stable and mature multipurpose programming language that works really well and has a massive community support. But, when is the release date of Python 4?

When is the Python 4 Release Date?

Short answer is unknown and not anytime soon.

Long answer is below. There has been speculation on Python 4’s release date for several years now. Especially, after the release of Python 3.9, quite a few people started thinking Python 4 might be due soon. However, that’s not how things work in the Pythonland.

The release of Python 4 might take many more years or in fact Python 4 might never arrive according to none other than Python’s founder Guido himself. The migration from Python 2 to Python 3 was painful because the programming language penetrated way too many applications, companies and practically Python is everywhere in our lives which magnified those incompatibility issues. Python applications depend on thousands of Python libraries which took time to get updated by their maintainers. Below you can find a more detailed explanation about when, if ever, Python 4.0 might be released.

Estimated Time

4 mins

Skill Level

Intermediate

Important Parameters

NA

Software

Cpython, C, Python

Python 4.0 and C libraries

Today Python 3 is quite stable and mature and the only foreseeable event that will cause Python 3 to be upgraded to Python 4 is, if the C libraries which Python interpreter uses (and the C extensions used to harvest their features in Python) become incompatible in the future.

Other than this fundamental reason, Python leadership and the community isn’t keen on making radical new changes unnecessarily especially after the years-long struggle during the transition from Python 2 to Python 3.

Python 4.0 and Global Interpreter Lock

Usage of C libraries by Python also required a thread-safe memory management solution such as GIL (Global Interpreter Lock). GIL does exactly what its name suggests: it locks the threads so they can’t run concurrently (on parallel). In computer a thread is a unit of a process that runs on a single CPU-core. If multiple threads are CPU-bound (requiring heavy usage of computation resources), running them concurrently introduces resource management issues and slows down the program’s execution.

Today however, most computers have multi-core processors which means Python doesn’t natively take advantage of multicore processing due to GIL’s single thread lock. This is the main reason why performance-focused developers and computer scientists are interested in removing GIL from Python altogether. This would require coming up with a new solution for thread-safe memory management. Currently, developers can try to overcome GIL’s performance flaws with Python’s multiprocessing library.

GIL solves a problem by locking threads so they don’t run concurrently. If GIL solution was removed from Python, this would slow down the way Python interpreter interprets Python code and especially the C extensions used in Python heavily rely on the GIL implementation. Long story short, removal of GIL is possible but unlikely due to compatibility and performance issues. If GIL was to be removed from Python one day this would also most likely mean introduction of Python 4.

We covered two events that would trigger the release of Python 4 which are both unlikely in the foreseeable future which is good news as Python is working like a hot knife through butter at the moment (in most cases).

GIL Benefits

Runtime Environment

  • In Python-specific context GIL enables single-threaded C extensions to run faster than they would otherwise.
  • In some cases GIL also makes single threaded applications to run faster.
  • Highly convenient compared to other solutions.
  •  GIL protects reference counters.
  • It’s possible to overcome GIL’s disadvantages using multiprocessing library.

GIL Disadvantages

Runtime Environment

  • GIL prevents multithreaded CPython applications from benefiting from multicore processors which are the norm today.
  • Multithreaded applications can’t be interpreted simultaneously.
  • Relatively slow execution time.
  • Scalability issues due to lack of multi-threading.

Removal of GIL from Python is an occasional hot topic in the Python community and to this date no one has come up with a feasible proposal that would replace Global Interpreter Lock.

What is Cpython or Cython?

Python’s source code is written in C language which was created in the 70s. You can view the Python source code written in C in this github repository.

From Cpython’s Wikipedia entry:

A particular feature of CPython is that it makes use of a global interpreter lock (GIL) on each CPython interpreter process, which means that within a single process, only one thread may be processing Python bytecode at any one time.

Python Interpreter's (Cpython) open source repository on Github has nearly 50K stars and 2K contributors.

Cpython or Cython is the standard implementation of the Python interpreter since Python interpreter mainly uses the C language and its libraries. Cpython translates Python code into bytecode which can be interpreted by the computers and is mainly written in C language.

Other variations also exist although they are not standard nor nearly as common as CPython. Those are Jython (JavaPython) which translates Python code into Java Bytecode and IronPython (C#) which translates Python into Microsoft-specific bytecode implementation.

Summary

In summary, we discussed Python 4’s unlikely release and the reasons behind it such as C extensions used in Cpython as well as the necessity to have a thread-related memory management solution such as Global Interpreter Lock.

Recommended Posts