[pypy-dev] How to translate 300000 lines of C

holger krekel hpk at trillke.net
Tue Jan 21 15:17:05 CET 2003


[Christian Tismer Tue, Jan 21, 2003 at 02:34:35PM +0100]
> Rocco Moretti wrote:
> > On another thread Christian Tismer <tismer at tismer.com> wrote:
> > 
> > 
> >>I tried to map [frameobject.c] on a 3.5 hour yourney from
> >>Kiel to Berlin, and I had one fourth done by an hour.
> >>Nevertheless, I got into trouble, just by comparing its
> >>implementation differences between 2.2.2 and 2.3a.
> >>Then I dropped that and decided that this is the wrong way.
> > 
> > 
> > I'm interested to know what problems you were encountering. 
> 
> Well, first of all, frameobject.c seemed to force
> me to invent every necessary supporting objects at once,
> or to drop them and maybe loose them.
> The block stack was one thing that I would have
> liked to describe with some struct construct,
> and there is pointer arithmetic...
> Well, this could have easily been replaced by
> a list of tuples.
> 
> But well, what really got me stuck was the number of
> changes and additions which came with 2.3a.
> With a direct rewrite in Python, we get into a major
> problem:
> You cannot use diffs any longer. Diffing between two
> C files is fine.
> But what do you do if you have a hand-written version
> of a C file? You have nothing to diff *that* against,

I see the problem.  But i hope that if we start with 
a minimal and clean python version then 

    a) we shouldn't have to change so often as 
       lots of details are abtracted out anyway.
       hopefully we only have to change the python-to-c 
       or python-to-assembler or python-to-objective-c 
       compilers. If at all.

    b) there could later be modules whose primary
       source is the pythonic version.  Similar 
       to the compiler package but note:
       most modules are simpler. 

    c) we might convince the python-dev folks later
       that testing out new PEPs or maintenance 
       takes place in the python version (prototype level)
       for specific parts.  Keeping the C-version up to date 
       is the problem then :-)

       This needn't be an all-or-nothing deal and
       hopefully could be done step-by-step. 

> so you have to read the C diffs, repeat the mappings
> which you did in brain and try to figure out what to
> change in the target .py file. Huh!
> 
> That really made me stop the otherwise not-so-hard
> transliteration and to think about how to avoid
> the upcoming nightmare.
> What I think is needed is a tool, that does the
> translation partially automatically, partially
> on my command, with some scripted rules.

*This* still seems like a nightmare to me. you
have the complexity for both developments (CPython
and PyPython) and the added complexity of syncing
them.  Unless your C-to-python translation is 
fully automatic. 

Note, that taking the 'pythonic code as primary 
ressource' route wasn't possible for the Jython
people at the time.  And they have a hard time
catching up. 

have fun with translators, anyway :-)

    holger


More information about the Pypy-dev mailing list