Hacker News new | comments | show | ask | jobs | submit login
[Django] Python 3 port - all tests now pass on 2.7.2 and 3.2.2 (groups.google.com)
282 points by praxxis 1763 days ago | hide | past | web | 53 comments | favorite



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.


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.


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


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.


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.


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. :)


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


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.


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.


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.


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/


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?



numpy and scipy are already Py3K-compliant. matplotlib is the odd one in the scientific community.


I was going to link to https://github.com/matplotlib/matplotlib-py3, but as of four days ago the 3.x branch was merged into the main repo: https://github.com/matplotlib/matplotlib.


Many of those have moved already.


You hit the nail on the head for me. Those are exactly the three packages I need before I can migrate.


Go back and check, they're all running on 3 already.

Have a good migration :)


Oops I spoke too soon. I still need panda3d.


pandas, numpy, and scipy all run on Python 3 now


Yes, sorry, I should have been more clear: there are communities (django developers or scientists or ...) whose buy-in of Python3 is crucial for its success. If they do not move to Python 3 it can just as well pack things now.


Django is a tiny part of the Python community as a whole. I've been doing python development for going on 12 years, and half the programmers I know use python professionally in one capacity or another, and I can honestly say I don't know a single person who gets paid use Django.


> I don't know a single person who gets paid use Django.

If not that, what sorts of work are they getting paid to do in Python?


Writing in house or custom desktop apps, data analysis/number crunching and visualizations in various fields, GIS work, non-web network services using twisted, and even web apps using other frameworks like werkzug, cherryPy and Zope/Plone. Other than low level embedded work, I can't think of a single area where I haven't heard of python being used.


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


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


Does this mean Werkzeug (and thus flask) will be ported in the foreseeable future?


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


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.


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


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?


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/)


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

This was built on top of existing work which was started years ago. For a lot of people it did appear come out of nowhere, but it wasn't like Vinay just woke up Monday morning and figured it all out right away.


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


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.


The 1.4 release is still a ways off and hasn't been branched off from the master; chances are this will be in 1.4.


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.


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?


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


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.


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


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


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


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


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/...


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.


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


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


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.


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.


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!


Was Greg Wilson teaching the Software Engineering course? :)


Yes, it was Greg's class.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: