Q1. How is this possible?
Manual memory management (which is what CPython does with it's counting) can be slower than automatic management in some cases.
Limitations in the implementation of the CPython interpreter preclude certain optimisations that PyPy can do (eg. fine grained locks).
As Marcelo mentioned, the JIT. Being able to on the fly confirm the type of an object can save you the need to do multiple pointer dereferences to finally arrive at the method you want to call.
Q2. Which Python implementation was used to implement PyPy?
The PyPy interpreter is implemnted in RPython which is a statically typed subset of Python (the language and not the CPython interpreter). - Refer http://codespeak.net/pypy/trunk/pypy/doc/architecture.html for details.
Q3. And what are the chances of a PyPyPy or PyPyPyPy beating their score?
That would depend on the implementation of these hypothetical interpreters. If one of them for example took the source, did some kind of analysis on it and converted it directly into tight target specific assembly code after running for a while, I imagine it would be quite faster than CPython.
Q4. why would anyone try something like this?
From the official site. http://codespeak.net/pypy/trunk/pypy/doc/architecture.html#id7
We aim to provide:
- a common translation and support framework for producing implementations of dynamic languages, emphasising a clean separation between language specification and implementation aspects.
- a compliant, flexible and fast implementation of the Python Language using the above framework to enable new advanced features without having to encode low level details into it.
By separating concerns in this way, we
intend for our implementation of
Python - and other dynamic languages -
to become robust against almost all
implementation decisions, including
target platform, memory and threading
models, optimizations applied, up to
to the point of being able to
automatically generate Just-in-Time
compilers for dynamic languages.
Conversely, our implementation
techniques, including the JIT compiler
generator, should become robust
against changes in the languages
implemented.
The C compiler gcc is implemented in C, The Haskell compiler GHC is written in Haskell. Do you have any reason for the Python interpreter/compiler to not be written in Python?