1. Pypy
  2. Untitled project
  3. extradoc

Source

extradoc / talk / strakt06 / run_example1.py

from pypy.translator.interactive import Translation
from pypy.annotation.model import SomeInteger

try:
    import rlcompleter2
    rlcompleter2.setup()
except ImportError:
    pass

import is_prime

t = Translation(is_prime.is_prime)
t.annotate([SomeInteger(nonneg=True)])
t.view()
t.rtype()
t.view()
t.backendopt(backend="c")
t.view()
f = t.compile()
print "value returned by the compiled function with argument 5"
print f(5)