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

You CANt teach an old dog new tricks

You CANt teach an old dog new tricks

Python has been around for 3 decades. A moment of silence as we let that sink in...

Since Python is such an "old" language, one doesn't expect it to have certain cool features that "modern" languages have. For instance, types baked into the language.

Well, this was the case a couple of years ago but this has changed. A lot of modern languages have "types" baked into the language. Some developers say having a good type system is as good as having the language writing tests for you (I totally disagree).

For my session, I will be exploring the type system of python. I'll go through the available tools, and share snippets on how types can make one write more maintainable and safer code.

Michael Bukachi

May 07, 2022
Tweet

More Decks by Michael Bukachi

Other Decks in Programming

Transcript

  1. Javascript - 4th December 1995 - 25 years C -

    1972 - 49 years C++ - 1985 - 36 years Java - 23rd May 1995 - 26 years Python - 20th February 1991 - 30 years Ruby - 1995 - 26 years Rust - 7th July , 2010 - 11 years GoLang - 10th November , 2009 - 12 years C# - 2000 -21 years Dart - 10th October, 2011 - 10 years Elixir - 2011 - 10 years Erlang - 1986 - 35 years Kotlin - 22nd July, 2011 - 10 years PHP - 8th June, 1995 - 26 years
  2. …Modern programming languages are developed to take the full advantages

    of modern computer hardware (Multi-core CPU, GPU, TPU), Mobile devices, large-set of data, fast networking etc.
  3. In a nutshell • Concise and terse code (less boilerplate)

    • Built-in support for concurrency • Null pointer safety • Type Inference • Much simpler feature set • Low cognitive load • Blend the best features of all programming paradigms
  4. —unknown “A good type system is as good as having

    the language write tests for you …”
  5. Javascript - 4th December 1995 - 25 years C -

    1972 - 49 years C++ - 1985 - 36 years Java - 23rd May 1995 - 26 years Python - 20th February 1991 - 30 years Ruby - 1995 - 26 years Rust - 7th July , 2010 - 11 years GoLang - 10th November , 2009 - 12 years C# - 2000 -21 years Dart - 10th October, 2011 - 10 years Elixir - 2011 - 10 years Erlang - 1986 - 35 years Kotlin - 22nd July, 2011 - 10 years PHP - 8th June, 1995 - 26 years
  6. DOES PYTHON NEED TYPE HINTS? • Mypy - Arguable the

    first, community driven • Pytype - Google • Pyright/Pylance - Microsoft • Pyre - Facebook & Instagram
  7. wHERE IT ALL STARTED? • PEP 484 - Type hints

    • 29th September 2014 • There’s a dedicated `typing` module
  8. wHat devs like to do? • Spin up that debugger

    (PDB away!) • Print statement with a combination of type() - (my former favourite!) • …..
  9. Until recently, type hints in python were used primarily for

    static type analysis i.e • You write your code • You run static type analysis against your code • You identify any issues • Rinse and repeat
  10. CREDITS: This presentation template was created by Slidesgo, including icons

    by Flaticon, infographics & images by Freepik and illustrations by Stories thanks Questions? @michaelbukachi Please keep this slide for attribution