[Python-ideas] Code version evolver
Steven D'Aprano
steve at pearwood.info
Thu Mar 14 19:02:40 EDT 2019
On Thu, Mar 14, 2019 at 09:33:21PM +0100, francismb wrote:
[...]
> > Do you mean something like 2to3? Something which transforms source code
> > written in Python?
> >
> Yes a source transformer, but to be applied to some 3.x version to move
> it to the next 3.x+1, and so on ... (instead of '2to3' a kind of
> 'nowtonext', aka 'python_next')
>
> Couldn't that relax the tension on doing 'backward compatibility
> changes' a bit ?
Perhaps, but probably not.
The core-developers are already overworked, and don't have time to add
all the features we want. Making them responsible for writing this
source code transformer for every backwards incompatible change will
increase the amount of work they do, not decrease it, and probably make
backwards-incompatible changes even less popular.
For example: version 3.8 will include a backwards incompatible change
made to the statistics.mode function. Currently, mode() raises an
exception if the data contains more than one "most frequent" value.
Starting from 3.8, it will return the first such value found.
If we had to write some sort of source code translator to deal with this
change, I doubt that we could automate this. And if we could, writing
that translator would probably be *much* more work than making the
change itself.
Besides, I think it was Paul who pointed this out, in practice we found
that 2to3 wasn't as useful as people expected. It turns out that for
most people, writing version-independent code that supports the older
and newer versions of Python is usually simpler than keeping two
versions and using a translator to move from one to the other.
But if you feel that this feature may be useful, I encourage you to
experiment with writing your own version and putting it on PyPI for
others to use. If it is successful, then we could some day bring it into
the standard library.
--
Steven
More information about the Python-ideas
mailing list