a quick Introduction to PyPy
Upcoming SlideShare
Loading in...5
×
 

a quick Introduction to PyPy

on

  • 4,644 views

 

Statistics

Views

Total Views
4,644
Views on SlideShare
3,896
Embed Views
748

Actions

Likes
0
Downloads
45
Comments
0

5 Embeds 748

http://ka010.wordpress.com 735
http://www.slideshare.net 8
http://avrdudes.soup.io 3
http://translate.googleusercontent.com 1
http://smarthome.soup.io 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

a quick Introduction to PyPy a quick Introduction to PyPy Presentation Transcript

  • PyPy Compiling Dynamic Language Implementations
  • The Python Situation
  • The Python Situation
      • lots of implementations
        • CPython - Posix
        • Jython - JVM 
        • IronPython - .NET
      • specialized projects
        • Stackless Python
        • unladen-swallow
        • Psyco
  • What PyPy is
      •  Python Implementation
      • Translation Framework
  • What PyPy is
      • Python implemented in Python 
  • What PyPy is
      • Python implemented in Python 
      • looks like this:
    $> python py.py
  • What PyPy is
      • Python implemented in Python 
      • looks like this:
      • runs on top of CPython
    $> python py.py
  • What PyPy is
      • Python implemented in Python 
      • looks like this:
      • runs on top of CPython
      • about 2000 times slower than CPython 
    $> python py.py
  • What PyPy is
    • 2.  Translation Framework 
    $> python py.py $> ./pypy-c  $> ./pypy-jvm $> ./pypy-cli
  • some PyPy facts
      • founded in 2003 by Holger Krekel and Armin Rigo
      • 2004 - 2007 EU Project - Sixth Framework
      • since 2007 Open Source Project
      • occasional Funding by Google
      • Sprint-Driven Development
  • PyPy Components
      • Architecture
      • RPython
      • Interpreter 
      • Translation Framework
  • PyPy components Architektur
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
        • Restricted = most possible static subset of Python  
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
        • Restricted = most possible static subset of Python  
        • required to perform Type Inference 
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
        • Restricted = most possible static subset of Python  
        • required to perform Type Inference 
        • input to the Translation Framework
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
        • Restricted = most possible static subset of Python  
        • required to perform Type Inference 
        • input to the Translation Framework
        • no real specification - just some hints
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
        • Restricted = most possible static subset of Python  
        • required to perform Type Inference 
        • input to the Translation Framework
        • no real specification - just some hints
        • used for writing interpreters
  • PyPy components RPython
      • RPython = Restricted/Reduced Python 
        • Restricted = most possible static subset of Python  
        • required to perform Type Inference 
        • input to the Translation Framework
        • no real specification - just some hints
        • used for writing interpreters
        • can be used for writing extensions as well
  • PyPy components Interpreter
  • PyPy components Interpreter
      • written in RPython
  • PyPy components Interpreter
      • written in RPython
      • Internals:
        • bytecode compiler -> generates bytecode
  • PyPy components Interpreter
      • written in RPython
      • Internals:
        • bytecode compiler -> generates bytecode
        • bytecode evaluator -> interprets bytecode 
  • PyPy components Interpreter
      • written in RPython
      • Internals:
        • bytecode compiler -> generates bytecode
        • bytecode evaluator -> interprets bytecode 
        • object space -> handles operations on objects
  • Python Interpreter
  • PyPy components Translation Framework
  • PyPy components Translation Framework
  • PyPy components Translation Framework
  • PyPy components Translation Framework
  •  
  • PyPy > CPython
      • High Level Language Implementation
      • JIT Generation
      • Object Spaces
      • Stackless
  • PyPy > CPython High Level Language Implementation
      • easy to experiment with 
  • PyPy > CPython High Level Language Implementation
      • easy to experiment with 
      • easy to implement new features
  • PyPy > CPython High Level Language Implementation
      • easy to experiment with 
      • easy to implement new features
        • lazily computed objects and functions
  • PyPy > CPython High Level Language Implementation
      • easy to experiment with 
      • easy to implement new features
        • lazily computed objects and functions
        • plug-able  garbage-collection 
  • PyPy > CPython High Level Language Implementation
      • easy to experiment with 
      • easy to implement new features
        • lazily computed objects and functions
        • plug-able  garbage-collection 
        • runtime replacement of live-objects 
  • PyPy > CPython High Level Language Implementation
      • easy to experiment with 
      • easy to implement new features
        • lazily computed objects and functions
        • plug-able  garbage-collection 
        • runtime replacement of live-objects
        • stackless concurrency 
  • PyPy > CPython JIT Generation
      • based on Partial Evaluation via Yoshihiko Futamura (1971). "Partial Evaluation of Computation Process – An Approach to a Compiler-Compiler"  
  • PyPy > CPython JIT Generation
      • based on Partial Evaluation via Yoshihiko Futamura (1971). "Partial Evaluation of Computation Process – An Approach to a Compiler-Compiler"
      • says:  it's possible to take an interpreter and transform it into a compiler
  • PyPy > CPython JIT Generation
      • based on Partial Evaluation via Yoshihiko Futamura (1971). "Partial Evaluation of Computation Process – An Approach to a Compiler-Compiler"
      • says:  it's possible to take an interpreter and transform it into a compiler
      • means: having such a thing is pretty cool because writing interpreters is a lot easier than writing compilers. 
  • PyPy > CPython JIT Generation
  • PyPy > CPython Object Spaces
      • Flow ObjSpace
      • Thunk ObjSpace
      • Taint ObjSpace
      • Dump ObjSpace
      • Transparent Proxies
  • Thunk Object Space
      • provides:
        • lazily computed objects 
        • lazily computed functions
        • globally replaceable objects
  • Thunk Object Space
      • provides:
        • lazily computed objects 
        • lazily computed functions
        • globally replaceable objects
      • is implemented in about 200 lines of code
  • Thunk Object Space
      • provides:
        • lazily computed objects 
        • lazily computed functions
        • globally replaceable objects
      • is implemented in about 200 lines of code
      • Example:
    >>>> a = "hello" >>>> b = "world" >>>> a + b 'helloworld' >>>> become(a,b) >>>> a + b 'worldworld'
  • Taint Object Space
      • provides protection for :
        • sensitive data that should not leak
  • Taint Object Space
      • provides protection for :
        • sensitive data that should not leak
      • provides protection from :
        • untrusted data that needs to be validated
  • Taint Object Space
      • provides protection for :
        • sensitive data that should not leak
      • provides protection from :
        • untrusted data that needs to be validated
      • Example:
    >>>> password = &quot;secret&quot; >>>> password 'secret' >>>> password = taint(&quot;secret&quot;) >>>> password Traceback (application-level):    File &quot;<inline>&quot;, line 1 in <interactive>      password TaintError
  • PyPy > CPython Stackless
      • infinite Recursion
        • CPython limited to depth=1000
        • regular PyPy limited to depth=5000
  • PyPy > CPython Stackless
      • infinite Recursion
        • CPython limited to depth=1000
        • regular PyPy limited to depth=5000
      • Microthreads
        • Coroutines
        • Tasklets and Channels
        • Greenlets
  • PyPy > CPython Stackless
      • infinite Recursion
        • CPython limited to depth=1000
        • regular PyPy limited to depth=5000
      • Microthreads
        • Coroutines
        • Tasklets and Channels
        • Greenlets
      • Coroutine Pickling
      • Coroutine Cloning 
  • Demo Lazy functions and objects Tainted objects Translator Shell