[pypy-dev] [pypydev] C to Python translation
Scott David Daniels
daniels at dsl-only.net
Tue Jan 21 19:44:11 CET 2003
As I read some of the plans here and do the standard
"Oooh, Good Idea; Oh No, there's a swamp; Oh, Maybe"
dance in my head, I had what might either be a flash of
inspiration or maybe a deep lack of insight:
Instead of having the C-to-Python compiler derived from lcc
(or whatever) in charge of generating python, maybe we
can make it track points corresponding to changes in the
in C programs.
Its job would be simpler: no code generation at all. Find
identifed points in a C module which may have changes in it,
and indicate the corresponding points "hand-translated" program.
This is in part simpler because the "hand-translated" program
can have comments (or something) indication what original source
range they came from. By original source range I do not
mean line, character, or token numbers, but locations that
are somehow rediscoverable with a parser on altered source.
At the roughest cut, this could be declarations and definitions,
but what level of detail you need these points should be much
clearer to Christian than to me.
A : original CPython source (version 2.33)
B : hand-translated version of A
Z : possibly unnecessary file describing the A->B mapping and
how identification points in A correspond to those in B
A': New improved CPython source for A (version 2.34)
The tool woud be responsible for taking as input:
a diff of A and A'
and producing change ranges in B in human readable form (and the
corresponding ranges in A and/or A'.
It would not automate any code semantics comparisons, but it could
focus the maintainer's attention on where changes might have effect.
This scheme might reduce the work of hand-tracking changes while
avoiding the nightmare of Python-in-name-only code that comes from
translating C code to python mechanically.
On the other hand, we have five fingers.
-Scott David Daniels
More information about the Pypy-dev