82
A Python for Future Generations Armin @mitsuhiko Ronacher

A Python for Future Generations

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Python for Future Generations

A Python for Future Generations

Armin @mitsuhiko Ronacher

Page 2: A Python for Future Generations

Hi, I'm Armin

... and I do Open Source,

lots of Python and SaaS

Flask Sentry

Page 3: A Python for Future Generations

… and here is where you

can find me

twitter.com/@mitsuhiko github.com/mitsuhiko lucumr.pocoo.org/

Page 4: A Python for Future Generations

‘raising awareness’

Page 5: A Python for Future Generations

the grass is always greener somewhere

Page 6: A Python for Future Generations

… what's Python anyway?

Page 7: A Python for Future Generations

Python is

whatever cpython does

Page 8: A Python for Future Generations

behavior & stdlib

Page 9: A Python for Future Generations

a + b = ?

Page 10: A Python for Future Generations

a.__add__(b) ?

Page 11: A Python for Future Generations

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

Page 12: A Python for Future Generations

a.__class__.__add__(a, b) ?

Page 13: A Python for Future Generations

they are all not necessarily correct

Page 14: A Python for Future Generations

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

Page 15: A Python for Future Generations

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

Page 16: A Python for Future Generations

gave us unclear behavior

when subclassing builtins

Page 17: A Python for Future Generations

there is no “+” operator

Page 18: A Python for Future Generations

there is PyNumber_Add and PySequence_Concat

Page 19: A Python for Future Generations

does it matter?

Page 20: A Python for Future Generations

debatable but … kinda?

Page 21: A Python for Future Generations

pypy, jython all copy the quirksbecause

Page 22: A Python for Future Generations

they want high compatibilitybecause

Page 23: A Python for Future Generations

users would not use it if it was not compatible

because

Page 24: A Python for Future Generations

prevents more innovative

language changes

Page 25: A Python for Future Generations

Python in 30 Years?

Page 26: A Python for Future Generations

make the python we use

more like the python we teach

Page 27: A Python for Future Generations

it's a common story

Page 28: A Python for Future Generations

python developers value compatibility

Page 29: A Python for Future Generations

distutils

implements original setup.py

Page 30: A Python for Future Generations

setuptoolsmonkey patches distutils to

support Python eggs

Page 31: A Python for Future Generations

pipmonkey patches setuptools on the

fly to manage python packages

Page 32: A Python for Future Generations

wheelmonkey patches setuptools to build wheels instead of eggs

Page 33: A Python for Future Generations

cffimonkey patches setuptools and

distutils to build extensions

Page 34: A Python for Future Generations

snaekmonkey patches cffi to build

Rust extension modules

Page 35: A Python for Future Generations

the GIL

Page 36: A Python for Future Generations

the only reason removing the GIL is hard is backwards compatibility

Page 37: A Python for Future Generations

looks like we're not good at breaking compatibility

Page 38: A Python for Future Generations

our only attempt was both radical and not

radical enough

Page 39: A Python for Future Generations

future of “scripting” languages

Page 40: A Python for Future Generations

they are here to stay

Page 41: A Python for Future Generations

but they will look different

Page 42: A Python for Future Generations

standards + ecosystem

Page 43: A Python for Future Generations

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

Page 44: A Python for Future Generations

where we did well

Page 45: A Python for Future Generations

interpreter code is readable

Page 46: A Python for Future Generations

ease of compilation

Page 47: A Python for Future Generations

extensibility

Page 48: A Python for Future Generations

flat dependency chains

Page 49: A Python for Future Generations

runtime introspection

Page 50: A Python for Future Generations

what we should probably do

Page 51: A Python for Future Generations

easier and clearer language behavior

Page 52: A Python for Future Generations

looking elsewhere

Page 53: A Python for Future Generations

JavaScript

Page 54: A Python for Future Generations

Rust

Page 55: A Python for Future Generations

both are new and modern both learned from mistakes

Page 56: A Python for Future Generations

packaging and modules

Page 57: A Python for Future Generations

packaging and modules

package.json Cargo.toml

Page 58: A Python for Future Generations

packaging and modules

• metadata is runtime available

• by default no code execution on installation

• (optionally) multiple versions per library

• public vs private / peer dependencies

Page 59: A Python for Future Generations

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?

Page 60: A Python for Future Generations

packaging and modules

• we can steal from others

• can target python 3 only if needed

realistic change?

Page 61: A Python for Future Generations

language standard

Page 62: A Python for Future Generations

language standard

• javascript: clarify interpreter behavior

• simplified language subset?

• generally leaner language?

• more oversight over language development

Page 63: A Python for Future Generations

language standard

• maybe micropython and other things can lead the way

• community can kill extension modules for CFFI

realistic change?

Page 64: A Python for Future Generations

unicode

Page 65: A Python for Future Generations

unicode

utf-8 everywhere wtf-8 where needed

Page 66: A Python for Future Generations

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

Page 67: A Python for Future Generations

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?

Page 68: A Python for Future Generations

extension modules

Page 69: A Python for Future Generations

extension modules

more cffi less libpython

Page 70: A Python for Future Generations

extension modules

• tricky for things like numpy

• generally possible for many uses

realistic change?

Page 71: A Python for Future Generations

linters & type annotations

Page 72: A Python for Future Generations

linters & type annotations

babel, eslint, … typescript, flow, …

Page 73: A Python for Future Generations

linters & type annotations

rustfmt, gofmt, prettier, …

Page 74: A Python for Future Generations

linters & type annotations

• maybe?

• typing in Python 3 might go this way

realistic change?

Page 75: A Python for Future Generations

what you can do!

Page 76: A Python for Future Generations

abuse the language less

Page 77: A Python for Future Generations

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

Page 78: A Python for Future Generations

class X(dict):

Page 79: A Python for Future Generations

stop writing non cffi extensions

Page 80: A Python for Future Generations

stop being clever with sys.modules

Page 81: A Python for Future Generations

awareness is the first step

Page 82: A Python for Future Generations

QA&