Maintaining a backported module

Ben Finney ben+python at benfinney.id.au
Thu Oct 24 06:01:51 EDT 2013


Steven D'Aprano <steve at pearwood.info> writes:

> 1) statistics.py in the standard library, which is written for 
>    Python 3.3/3.4 only, and should be as clean as possible;
>
> 2) a backport of it, on PyPI, which will support older Pythons, and
>    may be slower/uglier if need be.
>
> My problem is not supporting 2.7 and 3.4 in the one code base. My
> problem is, how do I prevent #1 and #2 from gradually diverging?

Generate one of them automatically from the other. My recommendation
would be to edit only the code written for Python 3.4, have a
fully-automatic generator for the code targeting Python 2.7, and ignore
all earlier versions.

How does the “3to2” tool <URL:http://pypi.python.org/pypi/3to2/> fare
with converting your code?

> The easy answer is "unit tests", but the unit tests for 1) are in the
> std lib and target 3.4, while the unit tests for 2) will be on PyPI
> and won't. So how do I keep the unit tests from diverging?

Again, I'd recommend you generate the Python 2 code automatically from
the actively-maintained Python 3 code.

-- 
 \     “Beware of and eschew pompous prolixity.” —Charles A. Beardsley |
  `\                                                                   |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list