[pypy-dev] Re: infos from the berlin-sprint (was Re: Sprint results?)
Florian Schulze
florian.proff.schulze at gmx.net
Sun Oct 5 21:21:59 MEST 2003
On Sun, 5 Oct 2003 18:36:32 +0200, holger krekel <hpk at trillke.net> wrote:
> Hi Florian,
Hi!
First: Thanks to Laura and Holger for the replies!
> So alltogether the Flowgraph/Functiongraph/flowmodel (there is no
> completly fixed terminology yet) is the central point for several
> independent algorithms that - if combined - eventually produce typed
> C-code.
>
> To sum it up there are the following abstractions:
>
> interpreter interpreting bytecode, dispatching operations on objects
> to
>
> objectspace implementing operations on boxed objects
>
> stdobjspace a concrete space implementing python's standard type
> system
>
> flowobjspace a conrete space performing abstract/symbolic
> interpretation and
> producing a (bytecode-indepedent) flowmodel of execution
>
> annotator analysing the flowmodel to infer types.
>
> genpyrex taking the (annotated) flowmodel to generate pyrex-code
>
> pyrex translating into an C-extension
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
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
...
>>> print pypy.translator.genpyrex.GenPyrex(space.build_flow(f)).emitcode()
def f():
v21 = 0
cinline "Label2:"
v22 = v21 < 10
if v22:
v24 = v21 + 1
v21 = v24
cinline "goto Label2;"
else:
v27, v28 = v21, v22
v29 = v27
return v29
Which is quite impressive in my opinion.
Regards,
Florian
More information about the pypy-dev
mailing list