[pypy-dev] Re: infos from the berlin-sprint (was Re: Sprint results?)

holger krekel hpk at trillke.net
Sun Oct 5 22:05:29 CEST 2003


[Florian Schulze Sun, Oct 05, 2003 at 09:21:59PM +0200]
> Just a few questions about this: As far as I can tell there is no script 
> yet, which just takes a python file and generates Pyrex code, correct? 
> What would be needed?
> - a way to get functions from a python module
> - build_flow from the flow object space which takes those functions and 
> generates a graph
> - GenPyrex from genpyrex.py which takes that graph and emits a pyrex 
> function

Maybe i should have pointed out that we are not at the point where
pypy takes any (RPython) python function, let alone unrestricted python. 

> I tried out the following with a normal python interpreter in the pypy/src 
> directory:
> 
> >>> import pypy.objspace.flow
> >>> space = pypy.objspace.flow.Space()
> >>> import pypy.translator.genpyrex
> >>> def f():
> ...     i = 0
> ...     while i < 10:
> ...             i = i + 1
> ...     return i
> ...

it is interesting to then continue with:

>>> flow = space.build_flow(f)
>>> genpyx = pypy.translator.genpyrex.GenPyrex(flow)
>>> genpyx.annotate([])   
>>> print genpyx.emitcode()
def f():
  cdef int i_v4
  cdef int i_v8
  cdef int i_v1
  cdef int i_v7
  cdef int i_v2
  cdef int i_v9
  i_v1 = 0
  cinline "Label2:"
  i_v2 = i_v1 < 10
  if i_v2:
    i_v4 = i_v1 + 1
    i_v1 = i_v4
    cinline "goto Label2;"
  else:
    i_v7, i_v8 = i_v1, i_v2
    i_v9 = i_v7
    return i_v9

which means you also get the type information.  

cheers,

    holger


More information about the Pypy-dev mailing list