Python Framework for developing dynamic languages etc. etc. From the user point of view An alternative to CPython with more features! antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 2 / 1
Python Framework for developing dynamic languages etc. etc. From the user point of view An alternative to CPython with more features! antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 2 / 1
Just Work (TM) ... unless they don’t :-) Programs that rely on CPython-specific behavior refcounting: open(’xxx’, ’w’).write(’stuff’) non-string keys in dict of types (try it!) exact naming of a list comprehension variable exact message matching in exception catching code ... Extension modules really? drum roll... antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 9 / 1
Just Work (TM) ... unless they don’t :-) Programs that rely on CPython-specific behavior refcounting: open(’xxx’, ’w’).write(’stuff’) non-string keys in dict of types (try it!) exact naming of a list comprehension variable exact message matching in exception catching code ... Extension modules really? drum roll... antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 9 / 1
Just Work (TM) ... unless they don’t :-) Programs that rely on CPython-specific behavior refcounting: open(’xxx’, ’w’).write(’stuff’) non-string keys in dict of types (try it!) exact naming of a list comprehension variable exact message matching in exception catching code ... Extension modules really? drum roll... antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 9 / 1
Just Work (TM) ... unless they don’t :-) Programs that rely on CPython-specific behavior refcounting: open(’xxx’, ’w’).write(’stuff’) non-string keys in dict of types (try it!) exact naming of a list comprehension variable exact message matching in exception catching code ... Extension modules really? drum roll... antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 9 / 1
Just Work (TM) ... unless they don’t :-) Programs that rely on CPython-specific behavior refcounting: open(’xxx’, ’w’).write(’stuff’) non-string keys in dict of types (try it!) exact naming of a list comprehension variable exact message matching in exception catching code ... Extension modules really? drum roll... antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 9 / 1
beta not 100% of CPython API is supported not included in PyPy 1.2 Known to work: wxPython (after a patch) _sre PyCrypto PIL antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 10 / 1
than Psyco) it may have a few bugs left (Psyco too) it is not a hack (unlike Psyco) PyPy also has excellent memory usage half that of CPython for a program using several hunderds MBs antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 17 / 1
than Psyco) it may have a few bugs left (Psyco too) it is not a hack (unlike Psyco) PyPy also has excellent memory usage half that of CPython for a program using several hunderds MBs antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 17 / 1
than Psyco) it may have a few bugs left (Psyco too) it is not a hack (unlike Psyco) PyPy also has excellent memory usage half that of CPython for a program using several hunderds MBs antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 17 / 1
bytecodes without a JIT, the bytecodes are then interpreted with a JIT, the bytecodes are further translated to machine code (assembler) antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 18 / 1
translate the whole functions into machine code “the obvious way” e.g. Pyrex/Cython, Unladen Swallow not good performance, or needs tricks semantic: translate bits of the function just-in-time only used parts exploit runtime information (e.g. types) Psyco, PyPy antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 19 / 1
translate the whole functions into machine code “the obvious way” e.g. Pyrex/Cython, Unladen Swallow not good performance, or needs tricks semantic: translate bits of the function just-in-time only used parts exploit runtime information (e.g. types) Psyco, PyPy antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 19 / 1
loops as they are executed turn them into machine code 80% of the time is spent in 20% of the code antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 20 / 1
are not, nicely handled by the JIT: loops, even across many calls, are nicely handled loops with very many taken paths are not e.g. Python programs that look like interpreters typical in tracing JITs bad support so far for generators and recursion antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 23 / 1
frame handling local variables are in CPU registers or on the C stack but sys._getframe() works correctly “virtuals”: temporary objects are not constructed e = a + b + c + d and much more complex examples attribute and method lookups, etc. antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 24 / 1
to maintain (or port to x86-64, etc.) reminder: works transparently for any Python code or any language (Prolog JIT :-) at PPDP 2010) viable alternative to CPython antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 26 / 1
missing extension modules (cpyext mitigates the problem) libraries that rely on CPython details ... clear performance-critical part antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 28 / 1
application PyPy: subprocess, runs only the hotspots How do they communicate? execnet The Ring of Python, Holger Krekel, 9:00 oups, too late :-) antocuni, arigato (Pycon Italia Qu4ttro) PyPy 1.2 May 8 2010 29 / 1