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

A Python for Future Generations

A Python for Future Generations

Keynote at EuroPython 2017 in Rimini.

Armin Ronacher

July 10, 2017
Tweet

More Decks by Armin Ronacher

Other Decks in Programming

Transcript

  1. A Python for Future
    Generations
    Armin @mitsuhiko Ronacher

    View Slide

  2. Hi, I'm Armin
    ... and I do Open Source,
    lots of Python and SaaS
    Flask
    Sentry

    View Slide

  3. … and here is
    where you
    can find me
    twitter.com/@mitsuhiko
    github.com/mitsuhiko
    lucumr.pocoo.org/

    View Slide

  4. ‘raising awareness’

    View Slide

  5. the grass is always greener somewhere

    View Slide

  6. … what's Python anyway?

    View Slide

  7. Python is
    whatever cpython does

    View Slide

  8. behavior & stdlib

    View Slide

  9. a + b = ?

    View Slide

  10. a.__add__(b) ?

    View Slide

  11. type(a).__add__(a, b) ?

    View Slide

  12. a.__class__.__add__(a, b) ?

    View Slide

  13. they are all not
    necessarily correct

    View Slide

  14. 1 0 LOAD_FAST 0 (a)
    3 LOAD_FAST 1 (b)
    6 BINARY_ADD

    View Slide

  15. which is “obj as num”.add
    or “obj as sequence”.concat

    View Slide

  16. gave us unclear behavior
    when subclassing builtins

    View Slide

  17. there is no “+” operator

    View Slide

  18. there is PyNumber_Add
    and PySequence_Concat

    View Slide

  19. does it matter?

    View Slide

  20. debatable but … kinda?

    View Slide

  21. pypy, jython all copy the quirks
    because

    View Slide

  22. they want high compatibility
    because

    View Slide

  23. users would not use it if it was
    not compatible
    because

    View Slide

  24. prevents more innovative
    language changes

    View Slide

  25. Python in 30 Years?

    View Slide

  26. make the python we use
    more like the python we teach

    View Slide

  27. it's a common story

    View Slide

  28. python developers
    value compatibility

    View Slide

  29. distutils
    implements original setup.py

    View Slide

  30. setuptools
    monkey patches distutils to
    support Python eggs

    View Slide

  31. pip
    monkey patches setuptools on the
    fly to manage python packages

    View Slide

  32. wheel
    monkey patches setuptools to
    build wheels instead of eggs

    View Slide

  33. cffi
    monkey patches setuptools and
    distutils to build extensions

    View Slide

  34. snaek
    monkey patches cffi to build
    Rust extension modules

    View Slide

  35. the GIL

    View Slide

  36. the only reason removing the GIL
    is hard is backwards compatibility

    View Slide

  37. looks like we're not good
    at breaking compatibility

    View Slide

  38. our only attempt was
    both radical and not
    radical enough

    View Slide

  39. future of “scripting” languages

    View Slide

  40. they are here to stay

    View Slide

  41. but they will look different

    View Slide

  42. standards + ecosystem

    View Slide

  43. if we want to be here in 30
    years, we need to evolve

    View Slide

  44. where we did well

    View Slide

  45. interpreter code
    is readable

    View Slide

  46. ease of compilation

    View Slide

  47. extensibility

    View Slide

  48. flat dependency chains

    View Slide

  49. runtime
    introspection

    View Slide

  50. what we should probably do

    View Slide

  51. easier and clearer
    language behavior

    View Slide

  52. looking elsewhere

    View Slide

  53. JavaScript

    View Slide

  54. Rust

    View Slide

  55. both are new and modern
    both learned from mistakes

    View Slide

  56. packaging and modules

    View Slide

  57. packaging and modules
    package.json
    Cargo.toml

    View Slide

  58. packaging and modules
    • metadata is runtime available
    • by default no code execution on installation
    • (optionally) multiple versions per library
    • public vs private / peer dependencies

    View Slide

  59. packaging and modules
    • we're moving away from setup.py install
    • pip is a separate tool
    • wheels
    • multi-version would require metadata access
    where are we now?

    View Slide

  60. packaging and modules
    • we can steal from others
    • can target python 3 only if needed
    realistic change?

    View Slide

  61. language standard

    View Slide

  62. language standard
    • javascript: clarify interpreter behavior
    • simplified language subset?
    • generally leaner language?
    • more oversight over language development

    View Slide

  63. language standard
    • maybe micropython and other things can lead
    the way
    • community can kill extension modules for CFFI
    realistic change?

    View Slide

  64. unicode

    View Slide

  65. unicode
    utf-8 everywhere
    wtf-8 where needed

    View Slide

  66. unicode
    • very little guessing
    • rust: operating system string type
    • rust: free from utf-8 to os-string and bytes
    • explicit unicode character APIs
    • emojis mean no basic plane

    View Slide

  67. packaging and modules
    • we would need to kill string slicing
    • utf-8 everywhere is straightforward
    • kill surrogate-escapes for a real os string?
    realistic change?

    View Slide

  68. extension modules

    View Slide

  69. extension modules
    more cffi
    less libpython

    View Slide

  70. extension modules
    • tricky for things like numpy
    • generally possible for many uses
    realistic change?

    View Slide

  71. linters & type annotations

    View Slide

  72. linters & type annotations
    babel, eslint, …
    typescript, flow, …

    View Slide

  73. linters & type annotations
    rustfmt, gofmt, prettier, …

    View Slide

  74. linters & type annotations
    • maybe?
    • typing in Python 3 might go this way
    realistic change?

    View Slide

  75. what you can do!

    View Slide

  76. abuse the language less

    View Slide

  77. sys._getframe(N).f_locals['_wat'] = 42

    View Slide

  78. class X(dict):

    View Slide

  79. stop writing non cffi extensions

    View Slide

  80. stop being clever with sys.modules

    View Slide

  81. awareness is the first step

    View Slide

  82. QA
    &

    View Slide