New Features in Python version 3.3 to 3.5

It’s been a while since the last time I read the Python technical documentations. In recent years, most of my jobs were related to Android. During that time, I’ve only used Python for small scripts. Nonetheless a few hours ago I read What’s New in Python 3.5. Filled with excitement, I visit What’s New in Python 3.4 and Python 3.3 too. Wow, there are loads of great features added in recent releases. Among others are:

  • lzma compression (version 3.3)
  • mock objects in unittest (version 3.3)
  • virtual environment (version 3.3)
  • pip (version 3.4)
  • asyncio (version 3.4)
  • enum (version 3.4)
  • type hints (version 3.5)

There are way more improvements beyond the above list. You can read the full list and explanations in the Python website.

The python powered logo

LZMA compression

LZMA (Lempel-Ziv-Markov Chain) is a very good compression algorithm available today. It was first used in 7z archive format. Usually it will give smaller archive size compared to gzip and bzip2, but requires more time for compression and decompression.

Mock objects

Mock objects are objects used as replacement of real objects during unit testing. When you write a test case, often the unit under inspection depends on a few foreign objects. You would need to instantiate those objects and then call methods of them. The problem is, since unit testing runs in isolation, building those objects can be very hard.

With mock objects, we can easily instantiate those dependencies. Not the real ones. Just dummies. Yes, mocking means that we create a fake object and supply it with fake data so that other code really think it is the real one.

Virtual environment

Every developer would work in many projects during his career. Every one of them is unique. For example, maybe a project uses the Flask framework with Redis, the next one would need Django, the next one uses PySide, etc. Some projects may even have conflicting dependencies. As a result, setting up project dependencies sometimes cause headache.

Virtual environment is a way to deal with this situation. It allows developers to set up an isolated environment and install libraries inside it. Now we manage many projects in the same machine at the same time without any problems.

Pip

Pip is a package manager for Python. It allows developers to install a package from a centralized server, along with its dependencies into her machine. It is similar to npm and Ruby gem.

Leave a Reply

%d bloggers like this: