Upgrade to Pro — share decks privately, control downloads, hide ads and more …

You Don't Care About Efficiency

Cory Benfield
September 06, 2015

You Don't Care About Efficiency

In this talk we’ll discuss why synchronous software is a problem, what your options are to move away from it, and what challenges are being faced by the Python ecosystem as we try to move towards a brave new asynchronous world.

Cory Benfield

September 06, 2015
Tweet

More Decks by Cory Benfield

Other Decks in Programming

Transcript

  1. You Don’t Care
    About
    Efficiency

    View Slide

  2. Hi

    View Slide

  3. @lukasaoz
    @lukasa

    View Slide

  4. View Slide

  5. Requests Core Contributor
    urllib3 Core Contributor
    Maintainer of 10+ others
    Hyper Maintainer

    View Slide

  6. You Don’t Care
    About
    Efficiency

    View Slide

  7. Synchronous
    Code is
    Dying

    View Slide

  8. View Slide

  9. The Problem

    View Slide

  10. Thesis:
    Synchronous
    Code is Hurting
    Software

    View Slide

  11. View Slide

  12. Why Is Software
    Slow?

    View Slide

  13. Responsiveness

    View Slide

  14. Synchronous

    Inefficient

    View Slide

  15. View Slide

  16. for url in urls:
    r = requests.get(url)
    do_stuff_with(r.content)

    View Slide

  17. Why Are We
    Synchronous?

    View Slide

  18. Easy
    Tools

    View Slide

  19. How Do I
    Async?

    View Slide

  20. is
    Problematic

    View Slide

  21. is
    Awesome

    View Slide

  22. from concurrent.futures import ThreadPoolExecutor
    def work(url):
    r = requests.get(url)
    do_stuff_with(r.content)
    with ThreadPoolExecutor(max_workers=10) as e:
    e.map(work, urls)

    View Slide

  23. View Slide

  24. Costs
    • Unfamiliar paradigms
    • Framework lock-in
    • Hard to support multiple
    frameworks (+sync code).

    View Slide

  25. Σ↑

    View Slide

  26. Synchronous Code

    Gratuitous Waste

    View Slide

  27. Asynchronous Code

    Beautiful Happiness

    View Slide

  28. View Slide

  29. Bonus:
    A Bold
    Prediction

    View Slide

  30. Thanks!
    ✨✨

    View Slide