Switch to Python 3…                                  Now…                               Immediately!                      ...
Interstitial AdvertisementCopyright © 2013 Russel Winder                       2
polemic           noun               a strong verbal or written attack on someone or somethingCopyright © 2013 Russel Wind...
IntroductionCopyright © 2013 Russel Winder                  4
2.6 2.7                                       2.5                                 2.4                      2.3           2...
3.3                                       3.2                                 3.1           3.0Copyright © 2013 Russel Win...
gs/2../3.3/gCopyright © 2013 Russel Winder                   7
So whats the problem?     ●   Python 2 remains the default Python.     ●   Too many people and organizations are far too  ...
So whats the solution?     ●   Python Software Foundation (PSF) should declare         Python 3 the default Python immedia...
But…world, we have a problem…     ●   …a few influential organizations are telling people         not to use Python 3 but ...
Recalcitrant organizations and projects                  should just pull their fingers out and                          s...
Or at least ensure their codebases               run under both Python 2 and Python 3.Copyright © 2013 Russel Winder      ...
Being Python 2 and 3 compatible     ●   2to3 not useful, its a one shot transform tool.     ●   six package might be usefu...
Embrace                                 managed and controlled                                        change.Copyright © 2...
Be agile.Copyright © 2013 Russel Winder               15
JustificationsCopyright © 2013 Russel Winder                    16
Python 2 is a dead end.                 Python 3 is the developing future.Copyright © 2013 Russel Winder                  ...
print(x)                                 exec(x)Copyright © 2013 Russel Winder              18
from __future__ import print_functionCopyright © 2013 Russel Winder                       19
from __future__ import (                                   division,                                   absolute_import,   ...
x = [x * x for x in range(100) if x % 10 == 0]Copyright © 2013 Russel Winder                                21
x = {x * x for x in range(100) if x % 10 == 0}Copyright © 2013 Russel Winder                                22
x = {x: x * x for x in range(100) if x % 10 == 0}Copyright © 2013 Russel Winder                                   23
Sadly (!) Python 2.7 is getting                     backports of things from Python 3.Copyright © 2013 Russel Winder      ...
Fortunately Python 2.6                                 and earlier are not.Copyright © 2013 Russel Winder                 ...
Python 2 is strict,                                 Python 3 is (sort of) lazyCopyright © 2013 Russel Winder              ...
map(lambda x: x * x,            filter(lambda x: x % 10 == 0, range(100))Copyright © 2013 Russel Winder                   ...
range(x)             tuple(range(x))                                 →                xrange(x)            range(x)Copyrig...
Not Sequences, but Iterators                  items                  keys                  values                  iterite...
CompetitionCopyright © 2013 Russel Winder                 30
Python is under challenge     ●   Go is taking over from Python for many people.          ●    Native, not interpreted.   ...
Native code languages are now                                 as expressive as Python.Copyright © 2013 Russel Winder      ...
And native code programs are                way, way faster than Python programs.Copyright © 2013 Russel Winder           ...
Statically compiled languages catch errors at                      compile time that are horrendous run                   ...
Are you concurrent?     ●   Whos using thread?     ●   Whos using threading?Copyright © 2013 Russel Winder                ...
Are you parallel?     ●   Whos using thread?     ●   Whos using threading?     ●   Whos using multiprocessing?Copyright © ...
At least IronPython and Jython                                 do not have a GIL as                                 CPytho...
Support the PyPy STM/AME experiment.Copyright © 2013 Russel Winder                        38
NB CSP stands for                       Concurrent Sequential ProcessesCopyright © 2011–2012 Russel Winder                ...
Dataflow                                            Operators connected by    Actors                                  chan...
Actors    Independent processes    communicating via    asynchronous exchange    of messagesCopyright © 2011–2012 Russel W...
Dataflow                                      Operators connected by                                      channels with ac...
CSP                                      Sequential processes                                      connected by channels  ...
Data Parallelism                                 Transform a sequence to                                 another sequence ...
Futures are the future.Copyright © 2013 Russel Winder                             45
Along with process pools                                    and thread pools.Copyright © 2013 Russel Winder               ...
Concurrent.futures     ●   Python 3.2 package to abstract over threads and         processes to give an asynchronous funct...
Talking of PyPy…Copyright © 2013 Russel Winder                      48
Support PyPy for Python 3.Copyright © 2013 Russel Winder                      49
ConclusionCopyright © 2013 Russel Winder                50
There are no real reasons                                 to stay with Python 2…Copyright © 2013 Russel Winder            ...
…so Python 3 should be                                 Considered mandatory.Copyright © 2013 Russel Winder                ...
ChallengeCopyright © 2013 Russel Winder               53
Problem                                                                  Python 3                Python 2                 ...
Interstitial AdvertisementCopyright © 2013 Russel Winder                       55
Switch to Python 3…                                  Now…                               Immediately!                      ...
Upcoming SlideShare
Loading in …5
×

Switch to Python 3…now…immediately

2,607 views

Published on

A presentation to The London Python Group (TLPG) 2013-02-12. A polemic against those who will not upgrade to Python 3.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,607
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Switch to Python 3…now…immediately

  1. 1. Switch to Python 3… Now… Immediately! Prof Russel Winder http://www.russel.org.uk email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winderCopyright © 2013 Russel Winder 1
  2. 2. Interstitial AdvertisementCopyright © 2013 Russel Winder 2
  3. 3. polemic noun a strong verbal or written attack on someone or somethingCopyright © 2013 Russel Winder 3
  4. 4. IntroductionCopyright © 2013 Russel Winder 4
  5. 5. 2.6 2.7 2.5 2.4 2.3 2.2Copyright © 2013 Russel Winder 5
  6. 6. 3.3 3.2 3.1 3.0Copyright © 2013 Russel Winder 6
  7. 7. gs/2../3.3/gCopyright © 2013 Russel Winder 7
  8. 8. So whats the problem? ● Python 2 remains the default Python. ● Too many people and organizations are far too afraid of change. Why do people and organizations become so afraid of change?Copyright © 2013 Russel Winder 8
  9. 9. So whats the solution? ● Python Software Foundation (PSF) should declare Python 3 the default Python immediately. People and organizations can implement this now: python → python2 replaced by: python → python3Copyright © 2013 Russel Winder 9
  10. 10. But…world, we have a problem… ● …a few influential organizations are telling people not to use Python 3 but to stay with Python 2, and…  Afraid of change? ● …some crucial projects cant or wont get Python 3 versions out.  Afraid of change? Many projects are now both Python 2 and  Python 3 or getting there very rapidly.Copyright © 2013 Russel Winder 10
  11. 11. Recalcitrant organizations and projects should just pull their fingers out and set Python 3 as their standard.Copyright © 2013 Russel Winder 11
  12. 12. Or at least ensure their codebases run under both Python 2 and Python 3.Copyright © 2013 Russel Winder 12
  13. 13. Being Python 2 and 3 compatible ● 2to3 not useful, its a one shot transform tool. ● six package might be useful in parts, and/or… ● …modernize package might help, but… ● …is manual the best?Copyright © 2013 Russel Winder 13
  14. 14. Embrace managed and controlled change.Copyright © 2013 Russel Winder 14
  15. 15. Be agile.Copyright © 2013 Russel Winder 15
  16. 16. JustificationsCopyright © 2013 Russel Winder 16
  17. 17. Python 2 is a dead end. Python 3 is the developing future.Copyright © 2013 Russel Winder 17
  18. 18. print(x) exec(x)Copyright © 2013 Russel Winder 18
  19. 19. from __future__ import print_functionCopyright © 2013 Russel Winder 19
  20. 20. from __future__ import ( division, absolute_import, print_function, unicode_literals, )Copyright © 2013 Russel Winder 20
  21. 21. x = [x * x for x in range(100) if x % 10 == 0]Copyright © 2013 Russel Winder 21
  22. 22. x = {x * x for x in range(100) if x % 10 == 0}Copyright © 2013 Russel Winder 22
  23. 23. x = {x: x * x for x in range(100) if x % 10 == 0}Copyright © 2013 Russel Winder 23
  24. 24. Sadly (!) Python 2.7 is getting backports of things from Python 3.Copyright © 2013 Russel Winder 24
  25. 25. Fortunately Python 2.6 and earlier are not.Copyright © 2013 Russel Winder 25
  26. 26. Python 2 is strict, Python 3 is (sort of) lazyCopyright © 2013 Russel Winder 26
  27. 27. map(lambda x: x * x, filter(lambda x: x % 10 == 0, range(100))Copyright © 2013 Russel Winder 27
  28. 28. range(x) tuple(range(x)) → xrange(x) range(x)Copyright © 2013 Russel Winder 28
  29. 29. Not Sequences, but Iterators items keys values iteritems → items iterkeys keys itervalues valuesCopyright © 2013 Russel Winder 29
  30. 30. CompetitionCopyright © 2013 Russel Winder 30
  31. 31. Python is under challenge ● Go is taking over from Python for many people. ● Native, not interpreted. ● Solid concurrency model – CSP ● D is hoping to take over from C, C++, Go, Python. ● Native, not interpreted. ● Solid concurrency models – actors, data parallelismCopyright © 2013 Russel Winder 31
  32. 32. Native code languages are now as expressive as Python.Copyright © 2013 Russel Winder 32
  33. 33. And native code programs are way, way faster than Python programs.Copyright © 2013 Russel Winder 33
  34. 34. Statically compiled languages catch errors at compile time that are horrendous run time bugs in dynamic languages.Copyright © 2013 Russel Winder 34
  35. 35. Are you concurrent? ● Whos using thread? ● Whos using threading?Copyright © 2013 Russel Winder 35
  36. 36. Are you parallel? ● Whos using thread? ● Whos using threading? ● Whos using multiprocessing?Copyright © 2013 Russel Winder 36
  37. 37. At least IronPython and Jython do not have a GIL as CPython and PyPy do.Copyright © 2013 Russel Winder 37
  38. 38. Support the PyPy STM/AME experiment.Copyright © 2013 Russel Winder 38
  39. 39. NB CSP stands for Concurrent Sequential ProcessesCopyright © 2011–2012 Russel Winder 39
  40. 40. Dataflow Operators connected by Actors channels with activity Independent processes triggered by arrival of communicating via data on the channels. asynchronous exchange of messages CSP Sequential processes connected by channels using synchronous message exchange (rendezvous).Copyright © 2011–2012 Russel Winder 40
  41. 41. Actors Independent processes communicating via asynchronous exchange of messagesCopyright © 2011–2012 Russel Winder 41
  42. 42. Dataflow Operators connected by channels with activity triggered by arrival of data on the channels.Copyright © 2011–2012 Russel Winder 42
  43. 43. CSP Sequential processes connected by channels using synchronous message exchange (rendezvous).Copyright © 2011–2012 Russel Winder 43
  44. 44. Data Parallelism Transform a sequence to another sequence where all individual actions happen at the same time.Copyright © 2013 Russel Winder 44
  45. 45. Futures are the future.Copyright © 2013 Russel Winder 45
  46. 46. Along with process pools and thread pools.Copyright © 2013 Russel Winder 46
  47. 47. Concurrent.futures ● Python 3.2 package to abstract over threads and processes to give an asynchronous function call and future system. cf. futures package for Python 2.Copyright © 2013 Russel Winder 47
  48. 48. Talking of PyPy…Copyright © 2013 Russel Winder 48
  49. 49. Support PyPy for Python 3.Copyright © 2013 Russel Winder 49
  50. 50. ConclusionCopyright © 2013 Russel Winder 50
  51. 51. There are no real reasons to stay with Python 2…Copyright © 2013 Russel Winder 51
  52. 52. …so Python 3 should be Considered mandatory.Copyright © 2013 Russel Winder 52
  53. 53. ChallengeCopyright © 2013 Russel Winder 53
  54. 54. Problem Python 3 Python 2 Is there a problem, the solution to which can be coded in Python 2, but not better in Python 3?Copyright © 2013 Russel Winder 54
  55. 55. Interstitial AdvertisementCopyright © 2013 Russel Winder 55
  56. 56. Switch to Python 3… Now… Immediately! Prof Russel Winder http://www.russel.org.uk email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winderCopyright © 2013 Russel Winder 56

×