Python 2 or Python 3

10 views
Skip to first unread message

David

unread,
Nov 9, 2010, 8:52:01 AM11/9/10
to python-radiance
This project is starting during the transition from Python 2.x to
Python 3.x. Somewhere between most and all of the newer features have
been backported to the Python 2 series of code so that it can Python 3
code. My opinion is that it should be written to be compatible with
Python 3, but still able to run in 2.7/2.6 because of all the
libraries that are available for that line (SciPy, PIL, etc.), plus
it's still the default installation on many systems.

Thoughts?

jelle

unread,
Nov 9, 2010, 9:03:09 AM11/9/10
to python-radiance
>>>My opinion is that it should be written to be compatible with Python 3, but still able to run in 2.7/2.6 because of all the libraries that are available for that line (SciPy, PIL, >>>etc.), plus it's still the default installation on many systems.

+1
excellent suggestion

Randolph M. Fritz

unread,
Nov 9, 2010, 9:20:35 AM11/9/10
to python-radiance
I think David has the right of it, here. BTW, does anyone know what
actually happened to the new Python imaging package described by
Mastrodomenico in PEP 368? It's been three years since that was
written, and nothing seems to have come of it.

Randolph

Thomas Bleicher

unread,
Nov 9, 2010, 9:27:38 AM11/9/10
to python-...@googlegroups.com
On Tue, Nov 9, 2010 at 9:20 AM, Randolph M. Fritz <rfr...@lbl.gov> wrote:
> I think David has the right of it, here. BTW, does anyone know what
> actually happened to the new Python imaging package described by
> Mastrodomenico in PEP 368? It's been three years since that was
> written, and nothing seems to have come of it.

There is a google code project here (just found it via google):

http://code.google.com/p/pyimage/


Thomas

jelle

unread,
Nov 9, 2010, 9:28:56 AM11/9/10
to python-radiance
I recommend VIPS since its radiance support is impeccable and its fast
and scalable, just like the radiance image processing tools.
http://www.vips.ecs.soton.ac.uk/index.php?title=VIPS

Thomas Bleicher

unread,
Nov 9, 2010, 9:46:20 AM11/9/10
to python-...@googlegroups.com
On Tue, Nov 9, 2010 at 8:52 AM, David <dbs...@gmail.com> wrote:

> My opinion is that it should be written to be compatible with
> Python 3, but still able to run in 2.7/2.6 because of all the
> libraries that are available for that line (SciPy, PIL, etc.), plus
> it's still the default installation on many systems.
>
> Thoughts?

I think the availability of other scientific packages is key here.
I have not spent much time with Python 3 yet but it seems to
me that the differences are subtle and should hardly affect the
logic of our code.

I can not exclude, though, that there are situations where we
will not find a solution that works in both 2.x and 3. In that case
I'd prefer to have two different implementations rather than tie
ourselves to one Python version only.

BTW: Can you have conditional code depending on the version
of Python or will older Python interpreters just complain about
the new syntax? I'm sure we can have bundles which are specific
to one Python version but it would be nice to have code for the
same feature all in one file.

How do you feel about an __init__.py that does this:

import sys
if sys.version_info[0] == 3:
import image3 as image
else:
import image


Thomas

Thomas Bleicher

unread,
Nov 9, 2010, 9:52:04 AM11/9/10
to python-...@googlegroups.com

Do you see this as part of the python-radiance package or is it
just a 3rd party app that can be used on the final images?

Looks curious, though.

Thomas

jelle

unread,
Nov 9, 2010, 9:54:55 AM11/9/10
to python-radiance
Python 3 is still very new and hardly seen in production. It'll take
another 18 - 24 months perhaps before we'll see that happen on a
larger scale.
If you write modern python, than there is no real need to worry about
python 3 compatibility.
My 2 cents; target what works, don't worry too much upfront.

jelle

unread,
Nov 9, 2010, 9:59:16 AM11/9/10
to python-radiance
> Do you see this as part of the python-radiance package or is it
> just a 3rd party app that can be used on the final images?

I think VIPS is very much aligned with the sort of processing we do in
Radiance and its high performance and is tile based and processes
*concurrently*.
With other packages you'll have to write .hdr support, PIL doesn't do
32 bits RGB nor tile based ( problematic in terms of memory
consumption ).
So I suggest to use VIPS as an image processing dependency.
The devs of VIPS are very reactive and professional folks, so that's
neat too.
I don't think there's really another way of processing Radiance image
in Python?
Don't take my word for it; have a good at building / apt-getting it,
one hell of a lib.

-jelle

Marija Velickovic

unread,
Nov 9, 2010, 10:13:29 AM11/9/10
to python-radiance
Hi to all,

Related to Python version definitely 2.x.
As all others already mentioned 3.0 is still not supported by other
Python packages, like numpy or PIL. Compiling these packages for
Python 3.x is not such a trivial job as it may look like.

Related to image processing, I have no experience with VIPS, so can't
say anything smart about it :)

For RadDisplay I worked a lot on code for Radiance image reading/
writing.
In first version of my code I rewrite most of the Radiance code for
images reading/writing into Python. But images reading/writing with
pure Python is veeery slow. So now we use faster option - compiled C
code as external modules for reading/writing. For compiling and
wrapping I use scipy.weave features (works on Linux and Windows). Not
sure if this solution is the best, but surely much faster then native
Python code.

Marija

jelle

unread,
Nov 9, 2010, 10:33:10 AM11/9/10
to python-radiance
> Compiling these packages for
> Python 3.x is not such a trivial job as it may look like.

True. The Python 3 support is somewhat academic.

Randolph M. Fritz

unread,
Nov 9, 2010, 12:15:53 PM11/9/10
to python-radiance
By the way, there is a discussion, "Should I use Python 2 or Python 3
for my development activity?" on the Python.org wiki.
http://wiki.python.org/moin/Python2orPython3

Randolph
Reply all
Reply to author
Forward
0 new messages