On 1/2/2014 12:36 PM, Robin Becker wrote:
I just spent a large amount of effort porting reportlab to a version
which works with both python2.7 and python3.3. I have a large number of
functions etc which handle the conversions that differ between the two
pythons.
I am imagine that this was not fun.
[For those who do not know, reportlab produces pdf documents.]
For fairly sensible reasons we changed the internal default to use
unicode rather than bytes.
Do you mean 'from __future__ import unicode_literals'?
Am I correct in thinking that this change increases the capabilities of
reportlab? For instance, easily producing an article with abstracts in
English, Arabic, Russian, and Chinese?
> After doing all that and making the tests
compatible etc etc I have a version which runs in both and passes all
its tests. However, for whatever reason the python 3.3 version runs slower.
Python 3 is slower in some things, like integer arithmetic with small ints.
2.7 Ran 223 tests in 66.578s
3.3 Ran 223 tests in 75.703s
I know some of these tests are fairly variable, but even for simple
things like paragraph parsing 3.3 seems to be slower. Since both use
unicode internally it can't be that can it, or is python 2.7's unicode
faster?
The new unicode implementation in 3.3 is faster for some operations and
slower for others. It is definitely more space efficient, especially
compared to a wide build system. It is definitely less buggy, especially
compared to a narrow build system.
Do your tests use any astral (non-BMP) chars? If so, do they pass on
narrow 2.7 builds (like on Windows)?
So far the superiority of 3.3 escapes me,
For one thing, indexing and slicing just works on all machines for all
unicode strings. Code for 2.7 and 3.3 either a) does not index or slice,
b) does not work for all text on 2.7 narrow builds, or c) has extra
conditional code only for 2.7.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list