Slide 1

Slide 1 text

PyPy status talk Carl Friedrich Bolz Antonio Cuni Samuele Pedroni EuroPython 2009 June 30 2009 cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 1 / 28

Slide 2

Slide 2 text

Part 1 Becoming complete cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 1 / 28

Slide 3

Slide 3 text

PyPy release 1.1 PyPy released version 1.1 in April 2009 cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 2 / 28

Slide 4

Slide 4 text

What is PyPy An alternate Python virtual machine for C/Posix, for .NET and for Java More generally, a way to implement interpreters for various languages cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 3 / 28

Slide 5

Slide 5 text

PyPy - motivation CPython is nice, but not flexible enough IronPython, Jython - bound to their specific VM Psyco and Stackless Python are hard to maintain cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 4 / 28

Slide 6

Slide 6 text

PyPy: generating a Python Interpreter high level Python specification! layer GCs, JIT, Stackless atop the spec generate interpreters for targets cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 5 / 28

Slide 7

Slide 7 text

Brief history of PyPy First sprint in 2003, about 30 more by now CPython/Psyco/Jython/Stackless developers participating MIT License EU Research project 2004-2007 2007-now - open source project Sponsoring from Google, Nokia Soon: cofunding for JIT work cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 6 / 28

Slide 8

Slide 8 text

PyPy 1.1 Compatible with Python 2.5.2 Well tested on Windows and Linux 32-bit, but should also work on Mac OS/X and Linux 64-bit Runs major packages unmodified, out of the box easy_install / distutils working cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 7 / 28

Slide 9

Slide 9 text

PyPy 1.1 - more supported packages ctypes cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 8 / 28

Slide 10

Slide 10 text

PyPy 1.1 - more supported packages ctypes sqlite cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 9 / 28

Slide 11

Slide 11 text

PyPy 1.1 - more supported packages ctypes sqlite array, cPickle, cStringIO, cmath, dbm, datetime, binascii... cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 10 / 28

Slide 12

Slide 12 text

PyPy 1.1 - more supported packages ctypes sqlite array, cPickle, cStringIO, cmath, dbm, datetime, binascii... __builtin__, __pypy__, _codecs, _lsprof, _minimal_curses, _random, _rawffi, _socket, _sre, _weakref, bz2, cStringIO, crypt, dyngram, errno, exceptions, fcntl, gc, itertools, marshal, math, md5, mmap, operator, posix, pyexpat, recparser, select, sha, signal, struct, symbol, sys, termios, thread, time, unicodedata, zipimport, zlib cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 11 / 28

Slide 13

Slide 13 text

PyPy 1.1 - speed Performance improved between 10% and 50% since PyPy 1.0 Python interpreter is now between 0.8 and 2x (and in some corner case 3-4x) slower than CPython It starts faster than CPython :-) Better garbage collectors (generational and hybrid) This is all ignoring the ongoing work on the JIT (part 2 of the talk, not in the 1.1 release) cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 12 / 28

Slide 14

Slide 14 text

PyPy 1.1 - sandboxing support Sandboxing: “virtualized”version of PyPy, safe to run any untrusted program cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 13 / 28

Slide 15

Slide 15 text

PyPy 1.1 - sandboxing support cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 14 / 28

Slide 16

Slide 16 text

PyPy 1.1 - sandboxing support It is a special version of PyPy that does not do any I/O Communicates purely on stdin/stdout Run by an outer controlling process (e.g. a CPython or a regular PyPy) Really safe by construction! cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 15 / 28

Slide 17

Slide 17 text

PyPy 1.1 - more news Stackless support complete (tasklet, frame pickling, greenlet) Classic classes on by default More memory-efficient (e.g. class instances are often only 50% of the size of CPython) _lsprof profiling cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 16 / 28

Slide 18

Slide 18 text

PyPy 1.1 - on CLR/.NET PyPy runs on the CLR and can now interface with .NET libraries (more work needed, though) PyPy runs on JVM too, but no integration there Contributors wanted! cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 17 / 28

Slide 19

Slide 19 text

PyPy 1.1 - on Maemo Cross-compliation: N810 Internet Tablet by Nokia Security, RAM usage, sharing interpreter state across processes... PyPy’s approach is good (not fully implemented yet) cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 18 / 28

Slide 20

Slide 20 text

What we can run We worked a lot on running existing applications on top of PyPy Sometimes requiring to change applications slightly Especially refcounting details tend to be a problem open(’xxx’, ’w’).write(’stuff’) cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 19 / 28

Slide 21

Slide 21 text

CTypes Part of CPython stdlib since 2.5 Official way to have bindings to external (C) libraries for PyPy Can handle i.e. pysqlite-ctypes, pyglet, pymunk or Sole Scion, almost whatever... Contribution to original ctypes (better errno handling, bugfixes, tests...) Part of Google sponsoring Note: a bit slow cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 20 / 28

Slide 22

Slide 22 text

Sqlite Part of CPython stdlib since 2.5 We use Gerhard Haering’s CTypes version Works reasonably well after some fixes Included in PyPy cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 21 / 28

Slide 23

Slide 23 text

Django We run unmodified Django 1.0 Only sqlite DB backend for now http://www.djangoproject.com http://code.djangoproject.com/wiki/DjangoAndPyPy cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 22 / 28

Slide 24

Slide 24 text

Pylons Worked almost out of the box once eggs were working (1 day) No SQLAlchemy yet, obscure problems ahead Unmodified, it passes all tests http://pylonshq.com/ cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 23 / 28

Slide 25

Slide 25 text

Twisted & Nevow Twisted works (60/4500 tests failing) Nevow works We don’t support PyCrypto nor PyOpenSSL and we won’t anytime soon (unless someone contributes a CTypes or RPython version) http://twistedmatrix.com/ cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 24 / 28

Slide 26

Slide 26 text

Other software Anything written in pure Python should just work :-) BitTorrent PyPy translation toolchain py lib SymPy Pinax Various smaller things, templating engines... cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 25 / 28

Slide 27

Slide 27 text

Obscure details that people rely on Non-string keys in dict of types Exact naming of a list comprehension variable Relying on untested and undocumented private stuff Exact message matching in exception catching code Refcounting details cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 26 / 28

Slide 28

Slide 28 text

Lessons Learned Lessons Learned: There is No Feature Obscure Enough for people not to rely on The pypy-c interpreter is probably far more compatible to CPython 2.5 than Jython or IronPython Main blocker for running apps is missing external modules cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 27 / 28

Slide 29

Slide 29 text

Contact / Q&A PyPy: http://codespeak.net/pypy Blog: http://morepypy.blogspot.com cfbolz, antocuni, pedronis (EuroPython 2009) PyPy status talk June 30 2009 28 / 28