[pypy-dev] type inference info derived from test suites for the tested?

holger krekel hpk at trillke.net
Mon Apr 17 13:13:08 CEST 2006


Hi Bengt, 

On Sat, Apr 15, 2006 at 15:03 -0700, Bengt Richter wrote:
> Please excuse if this is OT, but I was wondering about the subject topic,
> i.e., using a test code suite (run with special-command-line-option?)
> as a kind of substitute for pragmas within a language e.g. defining a function,
> and winding up with some intermediate representation of the constrained function
> that can be used in the compilation and linking of an application that does
> not include the function test suite per se, yet makes use of the implicit
> info from the test code (per command line option that caused the compiler's info
> transfer to the test-info-constrained-function's intermediate representation).

As far as PyPy's type inference is concerned: it starts from one entry
point and follows all possible code paths, annotating function arguments 
etc. with possible type(s).  If you are thinking about a set of disparate 
API functions (and not a coherent program) then tests could maybe be used 
to provide entry points.  

> Maybe this could also be viewed as a kind of global optimization using
> combined test and application code, but factoring out and pre-caching
> some results of separated function+test_function inferences, and editing
> out test code from the final linking.
>
> I guess this is trying to use test code as a general source of auxiliary
> information using inference as a way to be independent of particular
> languages' ability to express explicit type declarations or contracts etc.

Hum, well PyPy neccessarily does this already for transforming (R)Python 
programs to lower level representations (and does not make use of tests). 

Otherwise i doubt that the usual tests are exhaustive enough to implicitly
allow defining constraints on function arguments.  

> TIA for any pointers/urls where I might read about this kind of thing, and
> whether it's a dead end or a trail being explored, either in pypy or elsewhere.

i take it you have read PyPy's documentation ... nothing else i can
currently point to. 

cheers, 

    holger



More information about the Pypy-dev mailing list