[reportlab-users] Python 3000
Dirk Holtwick
dirk.holtwick at gmail.com
Fri Dec 5 11:28:46 EST 2008
Hi,
I think you should consider what Guido says about porting:
-----------------8<---------------[cut here]
Porting To Python 3.0
For porting existing Python 2.5 or 2.6 source code to Python 3.0, the
best strategy is the following:
0. (Prerequisite:) Start with excellent test coverage.
1. Port to Python 2.6. This should be no more work than the average port
from Python 2.x to Python 2.(x+1). Make sure all your tests pass.
2. (Still using 2.6:) Turn on the -3 command line switch. This enables
warnings about features that will be removed (or change) in 3.0. Run
your test suite again, and fix code that you get warnings about until
there are no warnings left, and all your tests still pass.
Run the 2to3 source-to-source translator over your source code tree.
(See 2to3 - Automated Python 2 to 3 code translation for more on this
tool.)
3. Run the result of the translation under Python 3.0. Manually fix up
any remaining issues, fixing problems until all tests pass again.
It is not recommended to try to write source code that runs unchanged
under both Python 2.6 and 3.0; you’d have to use a very contorted coding
style, e.g. avoiding print statements, metaclasses, and much more. If
you are maintaining a library that needs to support both Python 2.6 and
Python 3.0, the best approach is to modify step 3 above by editing the
2.6 version of the source code and running the 2to3 translator again,
rather than editing the 3.0 version of the source code.
-----------------8<---------------[cut here]
I think we should start to rewrite the basic parts of Reportlab using
unit tests and a clean API with documentation. In the second step the
flowables and stuff should be rethought and reimplemented. I think there
are a lot of ideas to optimize some central parts of Reportlab. I could
contribute paragraph implementation for example.
But I am afraid this will remain a dream for some time, since this would
be a really big effort and it is not that urgent to do the port now :(
Dirk
Andy Robinson schrieb:
> I've been pondering this more. I see 3 possible "branches"...
>
>
> (a) the present codebase running on 2.3 to 2.6. But we aim to remove
> dead code and examples, document and package a bit better, and make
> APIs a bit more explicit, so it's clearer what needs porting.
>
> (b) a Python 3.0 port which aims to present the same behaviour (and
> thus the same undocumented mishmash of APIs as we have now), but
> needing some significant internal rewrites to achieve it
>
> (c) a Python 3.0 port which aims to deprecate any stuff we don't need,
> properly take advantage of the clear distinction between
> natural-language text and byte-arrays, restructure anything we want
> to, and maybe catch up a bit with recent PDF specs. This would
> probably start off by porting just the lowest layers (pdfgen/pdfdoc)
> and we could try to build it up cleanly with good docco and test
> coverage as we go, in no rush.
>
> Does anyone here think (b) is worth pursuing to production quality,
> given that we have limited resources, and time spent on it would cut
> into time spent on (c)?
>
>
More information about the reportlab-users
mailing list