SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
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_winder


Copyright © 2013 Russel Winder                                  1
Interstitial Advertisement




Copyright © 2013 Russel Winder                       2
polemic
           noun
               a strong verbal or written attack on someone or something




Copyright © 2013 Russel Winder                                             3
Introduction




Copyright © 2013 Russel Winder                  4
2.6 2.7
                                       2.5
                                 2.4
                      2.3
           2.2

Copyright © 2013 Russel Winder                         5
3.3
                                       3.2
                                 3.1
           3.0
Copyright © 2013 Russel Winder                     6
gs/2../3.3/g



Copyright © 2013 Russel Winder                   7
So what's 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
So what's 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 → python3



Copyright © 2013 Russel Winder                                                9
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 can't or won't 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
Recalcitrant organizations and projects

                  should just pull their fingers out and

                          set Python 3 as their standard.




Copyright © 2013 Russel Winder                              11
Or at least ensure their codebases

               run under both Python 2 and Python 3.




Copyright © 2013 Russel Winder                             12
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
Embrace

                                 managed and controlled

                                        change.




Copyright © 2013 Russel Winder                            14
Be agile.




Copyright © 2013 Russel Winder               15
Justifications




Copyright © 2013 Russel Winder                    16
Python 2 is a dead end.

                 Python 3 is the developing future.




Copyright © 2013 Russel Winder                             17
print(x)



                                 exec(x)




Copyright © 2013 Russel Winder              18
from __future__ import print_function




Copyright © 2013 Russel Winder                       19
from __future__ import (
                                   division,
                                   absolute_import,
                                   print_function,
                                   unicode_literals,
                                 )




Copyright © 2013 Russel Winder                              20
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                                24
Fortunately Python 2.6

                                 and earlier are not.




Copyright © 2013 Russel Winder                          25
Python 2 is strict,

                                 Python 3 is (sort of) lazy




Copyright © 2013 Russel Winder                                26
map(lambda x: x * x,
            filter(lambda x: x % 10 == 0, range(100))




Copyright © 2013 Russel Winder                          27
range(x)             tuple(range(x))

                                 →
                xrange(x)            range(x)




Copyright © 2013 Russel Winder                         28
Not Sequences, but Iterators
                  items
                  keys
                  values
                  iteritems
                                 →       items
                  iterkeys               keys
                  itervalues             values


Copyright © 2013 Russel Winder                     29
Competition




Copyright © 2013 Russel Winder                 30
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 parallelism




Copyright © 2013 Russel Winder                                       31
Native code languages are now

                                 as expressive as Python.




Copyright © 2013 Russel Winder                              32
And native code programs are

                way, way faster than Python programs.




Copyright © 2013 Russel Winder                           33
Statically compiled languages catch errors at

                      compile time that are horrendous run

                           time bugs in dynamic languages.




Copyright © 2013 Russel Winder                                 34
Are you concurrent?
     ●   Who's using thread?
     ●   Who's using threading?




Copyright © 2013 Russel Winder                         35
Are you parallel?
     ●   Who's using thread?
     ●   Who's using threading?
     ●   Who's using multiprocessing?




Copyright © 2013 Russel Winder                       36
At least IronPython and Jython

                                 do not have a GIL as

                                 CPython and PyPy do.




Copyright © 2013 Russel Winder                            37
Support the PyPy STM/AME experiment.




Copyright © 2013 Russel Winder                        38
NB CSP stands for

                       Concurrent Sequential Processes




Copyright © 2011–2012 Russel Winder                       39
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
Actors
    Independent processes
    communicating via
    asynchronous exchange
    of messages




Copyright © 2011–2012 Russel Winder   41
Dataflow
                                      Operators connected by
                                      channels with activity
                                      triggered by arrival of
                                      data on the channels.




Copyright © 2011–2012 Russel Winder                             42
CSP
                                      Sequential processes
                                      connected by channels
                                      using synchronous message
                                      exchange (rendezvous).
Copyright © 2011–2012 Russel Winder                               43
Data Parallelism
                                 Transform a sequence to
                                 another sequence where all
                                 individual actions happen
                                 at the same time.




Copyright © 2013 Russel Winder                                44
Futures are the future.




Copyright © 2013 Russel Winder                             45
Along with process pools

                                    and thread pools.




Copyright © 2013 Russel Winder                              46
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
Talking of PyPy…




Copyright © 2013 Russel Winder                      48
Support PyPy for Python 3.




Copyright © 2013 Russel Winder                      49
Conclusion




Copyright © 2013 Russel Winder                50
There are no real reasons

                                 to stay with Python 2…




Copyright © 2013 Russel Winder                            51
…so Python 3 should be

                                 Considered mandatory.




Copyright © 2013 Russel Winder                           52
Challenge




Copyright © 2013 Russel Winder               53
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
Interstitial Advertisement




Copyright © 2013 Russel Winder                       55
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_winder


Copyright © 2013 Russel Winder                                  56

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (8)

What is XMPP Protocol
What is XMPP ProtocolWhat is XMPP Protocol
What is XMPP Protocol
 
XMPP 101
XMPP 101XMPP 101
XMPP 101
 
XMPP In Real Time
XMPP In Real TimeXMPP In Real Time
XMPP In Real Time
 
Network configuration
Network configurationNetwork configuration
Network configuration
 
Mastering Python 3 I/O (Version 2)
Mastering Python 3 I/O (Version 2)Mastering Python 3 I/O (Version 2)
Mastering Python 3 I/O (Version 2)
 
A Low-Power CoAP for Contiki
A Low-Power CoAP for ContikiA Low-Power CoAP for Contiki
A Low-Power CoAP for Contiki
 
Contiki Operating system tutorial
Contiki Operating system tutorialContiki Operating system tutorial
Contiki Operating system tutorial
 
XMPP & AMQP
XMPP & AMQPXMPP & AMQP
XMPP & AMQP
 

Mehr von Russel Winder

On Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseOn Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseRussel Winder
 
The Case for Kotlin and Ceylon
The Case for Kotlin and CeylonThe Case for Kotlin and Ceylon
The Case for Kotlin and CeylonRussel Winder
 
On the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layerOn the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layerRussel Winder
 
Fast Python? Don't Bother
Fast Python? Don't BotherFast Python? Don't Bother
Fast Python? Don't BotherRussel Winder
 
Making Python computations fast
Making Python computations fastMaking Python computations fast
Making Python computations fastRussel Winder
 
Tales from the Workshops
Tales from the WorkshopsTales from the Workshops
Tales from the WorkshopsRussel Winder
 
Making Computations Execute Very Quickly
Making Computations Execute Very QuicklyMaking Computations Execute Very Quickly
Making Computations Execute Very QuicklyRussel Winder
 
Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etcRussel Winder
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Russel Winder
 
Spocktacular testing
Spocktacular testingSpocktacular testing
Spocktacular testingRussel Winder
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular TestingRussel Winder
 
Is Groovy static or dynamic
Is Groovy static or dynamicIs Groovy static or dynamic
Is Groovy static or dynamicRussel Winder
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Russel Winder
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needRussel Winder
 
Are Go and D threats to Python
Are Go and D threats to PythonAre Go and D threats to Python
Are Go and D threats to PythonRussel Winder
 
Is Groovy as fast as Java
Is Groovy as fast as JavaIs Groovy as fast as Java
Is Groovy as fast as JavaRussel Winder
 
Who needs C++ when you have D and Go
Who needs C++ when you have D and GoWho needs C++ when you have D and Go
Who needs C++ when you have D and GoRussel Winder
 
Java 8: a New Beginning
Java 8: a New BeginningJava 8: a New Beginning
Java 8: a New BeginningRussel Winder
 

Mehr von Russel Winder (20)

On Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverseOn Concurrency and Parallelism in the JVMverse
On Concurrency and Parallelism in the JVMverse
 
The Case for Kotlin and Ceylon
The Case for Kotlin and CeylonThe Case for Kotlin and Ceylon
The Case for Kotlin and Ceylon
 
On the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layerOn the Architectures of Microservices: the next layer
On the Architectures of Microservices: the next layer
 
Fast Python? Don't Bother
Fast Python? Don't BotherFast Python? Don't Bother
Fast Python? Don't Bother
 
Making Python computations fast
Making Python computations fastMaking Python computations fast
Making Python computations fast
 
Tales from the Workshops
Tales from the WorkshopsTales from the Workshops
Tales from the Workshops
 
Making Computations Execute Very Quickly
Making Computations Execute Very QuicklyMaking Computations Execute Very Quickly
Making Computations Execute Very Quickly
 
Java is Dead, Long Live Ceylon, Kotlin, etc
Java is Dead,  Long Live Ceylon, Kotlin, etcJava is Dead,  Long Live Ceylon, Kotlin, etc
Java is Dead, Long Live Ceylon, Kotlin, etc
 
GPars Remoting
GPars RemotingGPars Remoting
GPars Remoting
 
Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.Java is dead, long live Scala, Kotlin, Ceylon, etc.
Java is dead, long live Scala, Kotlin, Ceylon, etc.
 
GPars 2014
GPars 2014GPars 2014
GPars 2014
 
Spocktacular testing
Spocktacular testingSpocktacular testing
Spocktacular testing
 
Spocktacular Testing
Spocktacular TestingSpocktacular Testing
Spocktacular Testing
 
Is Groovy static or dynamic
Is Groovy static or dynamicIs Groovy static or dynamic
Is Groovy static or dynamic
 
Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.Java is dead, long live Scala Kotlin Ceylon etc.
Java is dead, long live Scala Kotlin Ceylon etc.
 
Dataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you needDataflow: the concurrency/parallelism architecture you need
Dataflow: the concurrency/parallelism architecture you need
 
Are Go and D threats to Python
Are Go and D threats to PythonAre Go and D threats to Python
Are Go and D threats to Python
 
Is Groovy as fast as Java
Is Groovy as fast as JavaIs Groovy as fast as Java
Is Groovy as fast as Java
 
Who needs C++ when you have D and Go
Who needs C++ when you have D and GoWho needs C++ when you have D and Go
Who needs C++ when you have D and Go
 
Java 8: a New Beginning
Java 8: a New BeginningJava 8: a New Beginning
Java 8: a New Beginning
 

Kürzlich hochgeladen

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Kürzlich hochgeladen (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Switch to Python 3…now…immediately

  • 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_winder Copyright © 2013 Russel Winder 1
  • 3. polemic noun a strong verbal or written attack on someone or something Copyright © 2013 Russel Winder 3
  • 5. 2.6 2.7 2.5 2.4 2.3 2.2 Copyright © 2013 Russel Winder 5
  • 6. 3.3 3.2 3.1 3.0 Copyright © 2013 Russel Winder 6
  • 8. So what's 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. So what's 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 → python3 Copyright © 2013 Russel Winder 9
  • 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 can't or won't 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. Recalcitrant organizations and projects should just pull their fingers out and set Python 3 as their standard. Copyright © 2013 Russel Winder 11
  • 12. Or at least ensure their codebases run under both Python 2 and Python 3. Copyright © 2013 Russel Winder 12
  • 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. Embrace managed and controlled change. Copyright © 2013 Russel Winder 14
  • 15. Be agile. Copyright © 2013 Russel Winder 15
  • 17. Python 2 is a dead end. Python 3 is the developing future. Copyright © 2013 Russel Winder 17
  • 18. print(x) exec(x) Copyright © 2013 Russel Winder 18
  • 19. from __future__ import print_function Copyright © 2013 Russel Winder 19
  • 20. from __future__ import ( division, absolute_import, print_function, unicode_literals, ) Copyright © 2013 Russel Winder 20
  • 21. x = [x * x for x in range(100) if x % 10 == 0] Copyright © 2013 Russel Winder 21
  • 22. x = {x * x for x in range(100) if x % 10 == 0} Copyright © 2013 Russel Winder 22
  • 23. x = {x: x * x for x in range(100) if x % 10 == 0} Copyright © 2013 Russel Winder 23
  • 24. Sadly (!) Python 2.7 is getting backports of things from Python 3. Copyright © 2013 Russel Winder 24
  • 25. Fortunately Python 2.6 and earlier are not. Copyright © 2013 Russel Winder 25
  • 26. Python 2 is strict, Python 3 is (sort of) lazy Copyright © 2013 Russel Winder 26
  • 27. map(lambda x: x * x, filter(lambda x: x % 10 == 0, range(100)) Copyright © 2013 Russel Winder 27
  • 28. range(x) tuple(range(x)) → xrange(x) range(x) Copyright © 2013 Russel Winder 28
  • 29. Not Sequences, but Iterators items keys values iteritems → items iterkeys keys itervalues values Copyright © 2013 Russel Winder 29
  • 30. Competition Copyright © 2013 Russel Winder 30
  • 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 parallelism Copyright © 2013 Russel Winder 31
  • 32. Native code languages are now as expressive as Python. Copyright © 2013 Russel Winder 32
  • 33. And native code programs are way, way faster than Python programs. Copyright © 2013 Russel Winder 33
  • 34. Statically compiled languages catch errors at compile time that are horrendous run time bugs in dynamic languages. Copyright © 2013 Russel Winder 34
  • 35. Are you concurrent? ● Who's using thread? ● Who's using threading? Copyright © 2013 Russel Winder 35
  • 36. Are you parallel? ● Who's using thread? ● Who's using threading? ● Who's using multiprocessing? Copyright © 2013 Russel Winder 36
  • 37. At least IronPython and Jython do not have a GIL as CPython and PyPy do. Copyright © 2013 Russel Winder 37
  • 38. Support the PyPy STM/AME experiment. Copyright © 2013 Russel Winder 38
  • 39. NB CSP stands for Concurrent Sequential Processes Copyright © 2011–2012 Russel Winder 39
  • 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. Actors Independent processes communicating via asynchronous exchange of messages Copyright © 2011–2012 Russel Winder 41
  • 42. Dataflow Operators connected by channels with activity triggered by arrival of data on the channels. Copyright © 2011–2012 Russel Winder 42
  • 43. CSP Sequential processes connected by channels using synchronous message exchange (rendezvous). Copyright © 2011–2012 Russel Winder 43
  • 44. Data Parallelism Transform a sequence to another sequence where all individual actions happen at the same time. Copyright © 2013 Russel Winder 44
  • 45. Futures are the future. Copyright © 2013 Russel Winder 45
  • 46. Along with process pools and thread pools. Copyright © 2013 Russel Winder 46
  • 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. Talking of PyPy… Copyright © 2013 Russel Winder 48
  • 49. Support PyPy for Python 3. Copyright © 2013 Russel Winder 49
  • 50. Conclusion Copyright © 2013 Russel Winder 50
  • 51. There are no real reasons to stay with Python 2… Copyright © 2013 Russel Winder 51
  • 52. …so Python 3 should be Considered mandatory. Copyright © 2013 Russel Winder 52
  • 53. Challenge Copyright © 2013 Russel Winder 53
  • 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
  • 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_winder Copyright © 2013 Russel Winder 56