Backwards emulation rather than backwards compatibility?

Chris Liechti cliechti at gmx.net
Sat May 25 19:43:50 EDT 2002


Tim Churches <tchur at optushome.com.au> wrote in 
news:mailman.1022364102.10713.python-list at python.org:
...
> But Martin v. Loewis points out:
>> ...It is easy enough to install multiple
>> versions of the interpreter, though.
> 
> Indeed it is (unlike many other languages which make having
> multiple versions installed a nightmare), and these days the
> extra disc space used by multiple installations is not a concern. So...
> 
> How about a Python meta-bytecode-compiler/interpreter which examines
> Python source code and/or bytecode and automatically sends the code to 
> the appropriate installed version of Python, resetting PYTHONPATH and
> any other aspects of the environment appropriately?
> 
> Parsing the entire source and trying to infer which version of Python is
> appropriate would probably be too slow (and a big job to write...),
> so maybe an #ifdef-style directive could be put at the top of each 
> Python script which triggers the appropriate behaviour, such as 
> 
> import __v1.5.2__ 
> 
> The module __v1.5.2__ would do nothing, but that line in the source 
> would direct the meta-Python to use the correct version.
> 
> I'm not sure how such a meta-interpreter would deal with already
> compiled
> bytecode - is there a version stamp in the bytecode? 
> 
> If someone wants to write such a thing, I'd be happy to help test it...

that idea might sound nice, but it's too late! the problem are _old_ 
scripts that nobody wants to touch and so there is no possibility to 
include such an import statement (and even add a empty _v*_.py file to 
satisfy the import). for the same reason a "from __past__ import x" is 
useless. if an old script needs python 1.5.2, just change the first line to 
#/usr/bin/env python15 (on unix, windows in an other plagu^H^H^H^Hroblem)

if you're right now writing a module that has to be backward compatible, 
thats no problem, 'cause you can choose to only use features that exist in 
all python versions from 1.5.2 to 2.2.1.

the problem is to write a _forward compatible_ script - but we all don't 
know what the distant future wil bring up...

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list