KEMBAR78
Python 2 vs. Python 3 | PDF
{
Python  2  vs.  Python  3	
“event”:      “Python  BCN  Meetup  –  Beginners  session”	
“author”:  “Pablo  Enfedaque”	
“twi6er”:  “@pablitoev56”
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
>  December  1989:  Guido  Van  Rossum  starts  
Python  implementation	
>  January  1994:  Version  1.0  released	
>  October  2000:  Version  2.0  released	
>  December  2008:  Version  3.0  released	
>  June  2009:  Version  3.1  released	
>  July  2010:  Version  2.7  released  with  backports	
>  2014:  current  versions  are  2.7.6  and  3.4	
Python  versions
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
>  December  1989:  Guido  Van  Rossum  starts  
Python  implementation	
>  January  1994:  Version  1.0  released	
>  October  2000:  Version  2.0  released	
>  December  2008:  Version  3.0  released	
>  June  2009:  Version  3.1  released	
>  July  2010:  Version  2.7  released  with  backports	
>  2014:  current  versions  are  2.7.6  and  3.4	
WTF?!
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Python  3  is	
backwards  incompatible
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
>  Backwards  incompatibilities	
>  print  and  exec  become  functions	
>  All  classes  are  new-­‐‑style	
>  Massive  usage  of  generators  instead  of  lists	
>  All  text  (str)  is  Unicode  and  encoded  text  is  
binary  data  (bytes)	
>  Other  minor  changes  in  std  lib	
Python  3.0
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Why  Python  3?
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Mainly  because  of  encodings	
Why  Python  3?
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Google:  Python  encoding  sucks
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Google:  Python  3  sucks
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Really  because  of  encodings??	
Why  Python  3?
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Why  should  I  move  to  Python  3?
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
>  Proper  encoding	
>  asyncio	
>  enums	
>  Standard  library  virtualenvs	
>  Exception  chaining	
>  Single-­‐‑dispatch	
>  uni6est.mock	
>  contextlib	
>  “Be6er”  GIL	
>  concurrent.futures	
>  selectors  module	
>  Qualified  names	
>  …	
Python  3.4  new  features  (vs.  2.7)
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Why  people  don’t  use  Python  3?
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Why  people  don’t  use  Python  3?	
No  dependencies  ported
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Why  people  don’t  use  Python  3?	
Laziness?
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
>  Great  features  are  waiting  us  in  Python  3	
>  We  are  beyond  half  the  planned  life  of  Python  2.7	
>  Python  2.6  is  officially  retired  with  2.6.9  release	
>  Most  3rd  party  dependencies  already  in  Python  3	
>  Or  we  could  return  to  OSS  all  that  we  have  been  given	
>  hZps://caniusepython3.com	
>  Porting  to  Python  3  is  not  such  a  big  deal	
>  In  most  of  the  cases	
>  So,  no  more  excuses	
>  It’s  time  to  start  moving  to  Python  3	
Conclusions
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Conclusions
{  “event”:  “Python  BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”}	
	
Q&A	
Thanks  for  coming!	
	
	
Slides:  
h6ps://speakerdeck.com/pablito56/
python-­‐‑2-­‐‑vs-­‐‑python-­‐‑3  

Python 2 vs. Python 3

  • 1.
    { Python  2  vs. Python  3 “event”:      “Python  BCN  Meetup  –  Beginners  session” “author”:  “Pablo  Enfedaque” “twi6er”:  “@pablitoev56”
  • 2.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} >  December  1989:  Guido  Van  Rossum  starts   Python  implementation >  January  1994:  Version  1.0  released >  October  2000:  Version  2.0  released >  December  2008:  Version  3.0  released >  June  2009:  Version  3.1  released >  July  2010:  Version  2.7  released  with  backports >  2014:  current  versions  are  2.7.6  and  3.4 Python  versions
  • 3.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} >  December  1989:  Guido  Van  Rossum  starts   Python  implementation >  January  1994:  Version  1.0  released >  October  2000:  Version  2.0  released >  December  2008:  Version  3.0  released >  June  2009:  Version  3.1  released >  July  2010:  Version  2.7  released  with  backports >  2014:  current  versions  are  2.7.6  and  3.4 WTF?!
  • 4.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Python  3  is backwards  incompatible
  • 5.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} >  Backwards  incompatibilities >  print  and  exec  become  functions >  All  classes  are  new-­‐‑style >  Massive  usage  of  generators  instead  of  lists >  All  text  (str)  is  Unicode  and  encoded  text  is   binary  data  (bytes) >  Other  minor  changes  in  std  lib Python  3.0
  • 6.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Why  Python  3?
  • 7.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Mainly  because  of  encodings Why  Python  3?
  • 8.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Google:  Python  encoding  sucks
  • 9.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Google:  Python  3  sucks
  • 10.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Really  because  of  encodings?? Why  Python  3?
  • 11.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Why  should  I  move  to  Python  3?
  • 12.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} >  Proper  encoding >  asyncio >  enums >  Standard  library  virtualenvs >  Exception  chaining >  Single-­‐‑dispatch >  uni6est.mock >  contextlib >  “Be6er”  GIL >  concurrent.futures >  selectors  module >  Qualified  names >  … Python  3.4  new  features  (vs.  2.7)
  • 13.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Why  people  don’t  use  Python  3?
  • 14.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Why  people  don’t  use  Python  3? No  dependencies  ported
  • 15.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Why  people  don’t  use  Python  3? Laziness?
  • 16.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} >  Great  features  are  waiting  us  in  Python  3 >  We  are  beyond  half  the  planned  life  of  Python  2.7 >  Python  2.6  is  officially  retired  with  2.6.9  release >  Most  3rd  party  dependencies  already  in  Python  3 >  Or  we  could  return  to  OSS  all  that  we  have  been  given >  hZps://caniusepython3.com >  Porting  to  Python  3  is  not  such  a  big  deal >  In  most  of  the  cases >  So,  no  more  excuses >  It’s  time  to  start  moving  to  Python  3 Conclusions
  • 17.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Conclusions
  • 18.
    {  “event”:  “Python BCN  Meetup”,  “author”:  “Pablo  Enfedaque”,  “twi6er”:  “@pablitoev56”} Q&A Thanks  for  coming! Slides:   h6ps://speakerdeck.com/pablito56/ python-­‐‑2-­‐‑vs-­‐‑python-­‐‑3