KEMBAR78
Python3.6 and asynchronous programming | PDF
Python3.6
Asynchronous
Programming
ASYNC / AWAIT
Clock is running out….
 The Count down
 Porting code
 Futurize
 Best practices
 Pep8 and Autopep8
 Flake8
 Code that runs on both 2 and 3
Import this
Concurrent Vs Parallel
 Stackoverflow answer here
 Coroutines are control structures that run your methods
 Coroutines are nice to each other
 Event loops takes care of scheduling the coroutines
 Event loop use Select/Poll to schedule coroutines that wait for IO
Asynchronous Programming
 What?
 Order or execution is not predetermined
 Why?
 More readable and self documenting code
 Efficient as order execution is determined at run time
 Coroutines + Asynchronous programming go well together
 Most real world problems do not need multiple threads (I will prove this one)
 How?
 Boost.asio for C and C++ developers
 Twisted, Gevent, Eventlet, Tornado for python 2.7
 Asyncio, Curio for Python 3.6 (Standard library)
 Goroutines for Go
 Promise for Javascript
Still think threads are good?
Python loves Asynchronous
programming
 Pep255 Simple generators
 Pep342 Enhanced generators, the rise of coroutines
 Pep380 Delegating to Subgenerator
 Pep492 Coroutines and Asynchronous context managers with async
/ await (We are here)
 Pep3148 Future objects
 Pep525 Asynchronous Generators
 Pep530 Asynchronous Comprehension

Python3.6 and asynchronous programming

  • 1.
  • 2.
    Clock is runningout….  The Count down  Porting code  Futurize  Best practices  Pep8 and Autopep8  Flake8  Code that runs on both 2 and 3
  • 3.
  • 4.
    Concurrent Vs Parallel Stackoverflow answer here  Coroutines are control structures that run your methods  Coroutines are nice to each other  Event loops takes care of scheduling the coroutines  Event loop use Select/Poll to schedule coroutines that wait for IO
  • 5.
    Asynchronous Programming  What? Order or execution is not predetermined  Why?  More readable and self documenting code  Efficient as order execution is determined at run time  Coroutines + Asynchronous programming go well together  Most real world problems do not need multiple threads (I will prove this one)  How?  Boost.asio for C and C++ developers  Twisted, Gevent, Eventlet, Tornado for python 2.7  Asyncio, Curio for Python 3.6 (Standard library)  Goroutines for Go  Promise for Javascript
  • 6.
  • 7.
    Python loves Asynchronous programming Pep255 Simple generators  Pep342 Enhanced generators, the rise of coroutines  Pep380 Delegating to Subgenerator  Pep492 Coroutines and Asynchronous context managers with async / await (We are here)  Pep3148 Future objects  Pep525 Asynchronous Generators  Pep530 Asynchronous Comprehension