

[Django] Python 3 port - all tests now pass on 2.7.2 and 3.2.2 - praxxis
https://groups.google.com/forum/#!topic/django-developers/XjrX3FIPT-U

======
jacobian
You can find the code here: <https://bitbucket.org/vinay.sajip/django>. I'm
still trying this out myself, but one interesting thing to note is that Vinay
chose to use a single-source strategy instead of running things through 2to3.

~~~
bdarnell
Impressive! Is python 2.5 still supported? In my experience (with Tornado)
it's difficult to get a single codebase to work on 2.x and 3.x without using
some of the features introduced in 2.6.

~~~
wx77
Yes, in the latest development branch they dropped support for python 2.4
though.

------
jtchang
Freaking awesome. I have been watching the Python community slowly move to
Python 3 and to be honest it seems like the smoothest and most well planned
transition I've gone through.

Really early on they said Python 3 would break backward compatibility.
Normally I'd bitch and moan but they gave us plenty of time and knew it would
be a slow process.

Hopefully everyone will move to python 3 soon and we can just leave 2.x
cleanly.

~~~
Sami_Lehtinen
Way cool. Hopefully this also means that more hosters start supporting python
3.X. It's hard to find python hosting and even harder to find python 3.X
hosting. Often VPS has been the only practical solution.

~~~
arvinjoar
I use WebFaction. I know that there's a stigma against shared hosting, but
WebFaction has worked really well for my purposes so far. They have many
versions of python available and it just seems like they've been dogfooding or
something (they might just be good when it comes to taking in feedback) of
that nature, because it feels like they've covered all the bases. If anyone
sees this and wants to give them a try, add "?affiliate=arvinja" to the URL
and I will get a bit of money for it. :)

~~~
inovica
Just had a quick look and they seem to be very Python oriented. As a bit of
play space I might sign up with them. Thanks for the link

~~~
Hovertruck
For what it's worth, I've been using Webfaction for years now and while there
have been a few snags here and there, they're very reliable and have great
support.

------
yuvadam
This is an amazing milestone.

Once the Django community starts adopting Py3K, it's only a matter of time
before the rest of the Python community follows suit.

~~~
mynegation
Django is not the only killer app for Python. In fact I would argue that
scientific computing (numpy, scipy, pandas and friends) is no less, and in
fact, may be more of a factor in transitioning to Python 3.

~~~
dgallagher
After Django gets ported, the only thing keeping me from jumping to Python 3
is PIL. PIL has indicated that a 3.x-compatible version is in the works:
<http://www.pythonware.com/products/pil/>

~~~
briancurtin
The page has mentioned that for quite some time now, but I haven't heard of
any actual effort on that front. Does anyone know if there's progress there?

~~~
peterhunt
Don't know, but see: <http://hg.effbot.org/pil-2009-raclette>

------
myoffe
Sounds like great news! Will this be merged into the official Django project?

And, what does it mean for developers using Django? Will I be able to run
official Django 1.X on Py3k soon?

~~~
po
Yes, if it is accepted into the core then it means you will be able to run
Django on Python 3 soon. Keep in mind though that:

* This port was basically done in a week so many parts still need analysis and discussion. It's a huge step though.

* When Django says 'soon' it might not be what you expect if you are not used to the project. This is the type of thing that depends on a ton of compatibility testing. Django makes very measured, deliberate steps and this will likely not make the 1.4 release.

* Your Django project may depend on non-python3 libraries that keep you on the 2.x branch. You have to make sure all of your libraries are compatible. This does increase the pressure on those libraries to _get_ compatible though. (See <http://python3wos.appspot.com/>)

~~~
jdunck
There is no 2.x branch. This is a single codebase capable of running on both
py2 and py3.

~~~
po
A bit confusing… sorry. I meant to say the 2.x branch of python not Django
which I suppose is not really considered a branch but a whole other thing.

------
LeafStorm
I thought that the WSGI spec for Python 3 wasn't entirely settled yet. Was it
finished and approved while I wasn't looking?

~~~
jacobian
Yup, it was. PEP 3333 (<http://www.python.org/dev/peps/pep-3333/>) was
accepted and finalized this summer.

~~~
joeyespo
Does PEP 3333 take WebSockets and other long-running connections into account?

~~~
bdarnell
No, PEP 3333 is just an adaptation of the old WSGI interface (PEP 333) to
Python 3 (mostly bytes/unicode issues). PEP 444 will be the next version of
WSGI and will include some asynchronous functionality.

~~~
joeyespo
Ah! Thank you. Didn't know about that PEP. I _really_ look forward to it.

------
thedjpetersen
Congratulations to the Django team. This is a big step towards to the adoption
of python 3. The more big libraries that are ported the sooner we will see
wide spread adoption.

------
random42
This is a wonderful effort, but I dont understand point of the single source
approach, as 3.x branches are not backward compatible with 2.x branches.

Can someone (Vinay?) explain a simpleton (like me :)), the reasoning behind
using the single-source approach?

~~~
FraaJad
Maintaining two code bases is difficult than maintaining one, isn't it?

~~~
cdavid
To be fair, the idea has never been to maintain two code bases, but to re-run
the 2to3 when building/installing.

In practice, I find this quite pain to deal with (2to3 is slow, hard to use
when you need to support python 2.3 or 2.4, etc...), and much easier to just
do the 2/3 compatible source codebase. Various projects use the same approach,
but this is a tradeoff that will depend on a per-project basis.

------
flexterra
Wow, this was really fast. Congrats to the team.

~~~
hello_moto
Seems like a one-man effort as opposed to the team (or maybe I'm wrong).

~~~
arctangent
My understanding is that the core Django team were unaware of this effort
until just now.

~~~
simonw
The core team have been aware of this work since it started.

~~~
arctangent
I was basing my comment on the email from Jannis Leidel [1]:

"I'm a bit concerned that you didn't get in touch with us before you started
with the work, since tracking the changes would have been easier. FWIW, Martin
von Löwis, Alex and me would be those you can ask if you need any further
help"

Unless I'm missing something, it seems fairly clear that Vinay Sajip (plus
collaborators) did this entirely without the knowledge of the Django core
team... or at least some of them!

[1] [http://groups.google.com/group/django-
developers/browse_frm/...](http://groups.google.com/group/django-
developers/browse_frm/thread/4f7d1b091f163bb0?pli=1)

~~~
simonw
Hah, I'd missed that. I thought you were talking about the overall effort to
port to Python 3, not the particular flurry of activity from Vinay.

------
shuzchen
This is totally cool. I applaud these efforts. That said, I'm more interested
in switching to pypy than to py3 at the moment.

------
briancurtin
Is this based on Martin von Löwis' previous 3.x porting work?

~~~
jacobian
Yes, although in the end Vinay moved in a different direction (single shared
source instead of 2to3). I'm really interested in diving in and figuring out
some of the pros and cons of that approach; I hadn't thought it as going to be
possible on a codebase like Django.

~~~
briancurtin
fijal responded on the reddit post of the same topic about how sys.exc_info is
dog slow under PyPy, so the dances you have to do for exception handling will
probably rank highly in the con list. They're also pretty shitty looking.

Edit: you already responded over there, never mind.

------
Slimy
I'm one of the students from UofT that helped with this project. Basically, my
group for one of our Software Engineering courses had the assignment of
helping with this enormous task. We didn't finish (this was two years ago),
but we did make a lot of progress (fixing bugs to get the tests to pass in
both versions). It was one hell of a goal so it's great to see this finally
done!

~~~
azth
Was Greg Wilson teaching the Software Engineering course? :)

~~~
kingkilr
Yes, it was Greg's class.

