[Tutor] 2 vs 3
Steven D'Aprano
steve at pearwood.info
Sat Sep 5 15:25:41 CEST 2015
On Sat, Sep 05, 2015 at 03:06:25PM +0200, Sithembewena Lloyd Dube wrote:
> Hi all,
>
> A colleague and I are embarking on a project for a client. We have agreed
> to implement a REST API in Falcon (www.falconframework.org) and colleague
> wants to implement it in Python 3.
>
> Are there any advantages/ disadvantages of using Python 3? I have always
> stuck to Python 2.
Advantages of Python 2:
=======================
- More tutorials and websites about Python 2.
- Slightly faster for some operations.
- Some operations with mixed Unicode text + bytes succeed without
raising an exception; the result isn't what you want, but if you
are the sort of programmer who thinks that it is better to get the
wrong answer with no error instead of an error, you might think
this is an advantage.
- Some libraries are available for Python 2 but not 3 yet.
Advantages of Python 3:
=======================
- All on-going development of the language and new features will go
into Python 3.
- Cleaner, more consistent language: only one type of class, not
two; no longer has the proliferation of similar dictionary
methods (e.g. keys, iterkeys, viewkeys); std lib is organised
a bit better.
- Useful new features that Python 2 does not have, such as Enums,
asyncio, pathlib, and others.
- __del__ finalizer methods are easier and safer now.
- Cleaner separation between Unicode text and bytes. If you accidently
mix them together, you get an exception, instead of Python trying to
guess what result you might want.
- More efficient and cleaner handling of .pyc files.
If you decide to use Python 3, 3.3 should be the oldest version you
consider. 3.4 has many improvements and you should consider using that.
--
Steve
More information about the Tutor
mailing list