Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Python 3 (or later) better than Python 2?

I learned Python as my first serious (non BASIC) language about 10 years ago. Since then, I have learned lots of others, but I tend to 'think' in Python. When I look at the list of changes I do not see one I need this feature. I usually say to myself, hmm that would been a good way of doing it, but why change it now?

Things like changing the default floor division could be a real pain to change for big projects. It seems like the major players are dragging their feet. What is the key feature that would make me want to invest in another learning curve?

like image 570
nate c Avatar asked Aug 02 '10 00:08

nate c


People also ask

Why is Python 3 better than Python 2?

Python 3 is more in-demand and includes a typing system. Python 2 is outdated and uses an older syntax for the print function. While Python 2 is still in use for configuration management in DevOps, Python 3 is the current standard. Python (the code, not the snake) is a popular coding language to learn for beginners.

Is it better to learn Python 2 or 3?

In the past, there was a bit of a debate in the coding community about which Python version was the best one to learn: Python 2 vs Python 3 (or, specifically, Python 2.7 vs 3.5). Now, in 2018, it's more of a no-brainer: Python 3 is the clear winner for new learners or those wanting to update their skills.

Is python3 faster than Python 2?

So is Python 3 faster than Python 2? Yes! in almost all tests. The notable exceptions were the crypto_paes test, where Python 3 was 1.35x slower (because of the integer types), python_startup as 1.39x slower.


3 Answers

As a key feature, a lot of people seem to be pretty exited about (supposedly) transparent unicode support. They changed it from str (8-bit char array/default string type) and unicode (unicode string), to str (default (unicode compatable) string) and bytes (binary data as 8-bit 'string').

(I think seperation of byte lists from strings is great idea, but I also hate unicode, so if anything, this would be a worse for me personally.)

like image 130
David X Avatar answered Oct 12 '22 09:10

David X


A good discussion of this can be found in the python wiki; Should I use Python 2 or Python 3 for my development activity?

like image 20
Noctis Skytower Avatar answered Oct 12 '22 09:10

Noctis Skytower


Things like changing default floor division could be a real pain to change for big projects.

If you had started making the change 8 years ago when Python 2.2 was introduced with // and from __future__ import division, it wouldn't be a pain now. Personally, I'm glad to finally get rid of old-style division!

My second-favorite feature of Python 3.x is the str/bytes distinction. Besides making Unicode support easier, bytes is far more convenient for database BLOBs than buffer was.

like image 29
dan04 Avatar answered Oct 12 '22 10:10

dan04