Unladen Swallow: Python 3’s Best Feature.

holy-shit-awesome-2.jpgWe all know (well – unless you’ve under a rock) about Unladen-Swallow, the semi-Google-Sponsored optimization-focused branch of Python 2.x. Collin, Jeffrey and many others have been working tirelessly on porting the CPython interpreter over to LLVM, applying optimization patches, writing tests, etc all aimed at speeding up real-world operations and code since before last year’s PyCon – at that time, the first release was already working hard, rendering YouTube’s templates. (See the Project Plan for more information)

You probably also saw the 2009Q3 testing/performance results (here), showing a hefty speed increase for various operation. The 2009Q4 will be coming soon.

What you probably don’t know – yet, is that a PEP is coming, proposing Unladen Swallow be merged back to Python-core – specifically, the Python 3k branch. Yeah, that’s right – a PEP to merge Unladen Swallow back into the mothership, but to Py3k only. Talk about a shot in the arm!

Quoting Collin Winter:

Python 3 is the natural place for something like Unladen Swallow to land: Python 3 is clearly the future, and I think improved performance will be a strong selling point in the language’s favor. What we and others have done for Python 2 applies directly to Python 3.

One of the things we’ve really focused on with Unladen Swallow is creating a solid foundation that the wider CPython developer community can build on top of. We’ve fixed some nasty problems in the x86-64 JIT, for example, so that the CPython community can focus on the fun stuff — more optimizations! Having the basic JIT infrastructure in place and well-tested opens up a world of opportunities that didn’t exist before.

I think PyPy’s focus on research is incredibly valuable. Unladen Swallow has always been about, “what can we achieve right now?” One of our guiding principles has been, Do nothing original, don’t be innovative. PyPy is looking 10 years down the road and thinking, What can we do if we question everything? I think having those different perspectives is important to the community. So, no, I don’t see us in competition (with PyPy) at all.

There’s been a lot of talk about how slow adoption of 3k has been – a backwards incompatible implementation of a widely used language will always have slow(er) adoption then releases of the same language, backwards compatible – but I’d argue that to an extent, part of the reason is that there “haven’t been enough carrots” in the Py3k cart to provide enough of an incentive for projects, libraries, etc to move to it at an accelerated rate.

This, well – this changes things. A significantly faster interpreter, a more rational GIL thanks to Antoine Pitrou – these are the improvements to Python 3 which make it the perfect target to aim for for new projects and libraries. It should drastically help provide the impetus for larger libraries to move over. Things like these are exactly why something like the moratorium make sense, efforts can be focused on the ecosystem of python outside of the syntax, on the interpreter, the standard library, etc.

This is huge; and with a little luck, a lot of discussion and debate – and a ton of work, by the end of 2010, we’ll have not only the best implementation of Python, as a language to date in Python 3 – but the best interpreter as well.

The PEP should go out for review soon, probably within the next two weeks – and more details/information will be coming out at PyCon in February (you’re coming, right?!).

Also see Michael Foord’s post about this news too.

  • Stu
    Hm, as far as I remember the problem was that unladen swallow is based on LLVM which isn't available on as many platforms as CPython is.
    This would mean that the original implementation would have to hang around until LLVM became available on all the other architectures.
  • Toot
    That seems like an ambitious undertaking. But Python 3 really needs something special to attract people. Right now it seems way to little benefit for a lot of pain of not being able to use older packages.

    But putting it into Python 3 for the "sole" purpose of being the carrot - when in fact it currently runs with python 2.X - that's a little bit questionable.
  • No, I'm not coming to PyCon, so you better keep me updated. ;-) This is fantastic news, I hope it will happen.
  • I will try to! :)
  • Isn't unladen swallow developing against Python 2.6? Are they planning to make a Python 3 version?
  • They are currently developing against trunk (2.7) however; given their focus is on the bytecode layer, the transition to Python 3 syntax is relatively simple(ish).
  • Peter
    Part of the problem with Py3k is that many of the users don't agree it is better. The new print syntax is broken. We can no longer format strings the old fashioned way. Both of these "improvements" are big downgrades. People don't know what makes good languages. Some languages get lucky, and end up very usable. Python did. Python 3k didn't. Time to move on.
  • Masklinn
    > The new print syntax is broken.

    How? (and not only do I don't see how it's broken, I do find it much better than the previous one especially when doing anything beyond a vanilla print)

    > We can no longer format strings the old fashioned way.

    You are wrong. The '%' operator is considered obsolete in Python 3, but it's still here: http://docs.python.org/3.1/library/stdtypes.htm...

    IOW, you don't give any justification to your first declaration and the second one is plain wrong.

    > Python 3k didn't.

    Python 3 is a better and more useable language than Python 2 on pretty much every front. The only thing it's missing is libraries adoption, and I trust that this will right itself within a year or two at worst.
  • The new print syntax is better (see what I did there?) - you can still
    format strings the old way.
  • Good plan!
    This is exactly the sort of push I need to get me to move to Python 3.
  • Magnus Lyckå
    It's about time to stop using RHEL 5, and it's about time to let go of Python 2.5 support. Once that's done, once 2.6 is the oldest platform to support for 3rd party libraries, supporting Python 3 become much less of a challenge.
  • Typing this a second time as my login seems to have triggered a pre-POST submission text box digestion.

    I agree with this from a techie perspective. I think it's a great idea to merge the Unladen Swallow code and the CPython proper. It can only mean good things for the community as a whole. At the very least, it ought to serve as a boon for Py3K development.

    Though, I keep going back to the fact that I don't necessarily use Python for its speed. If I want speed, it's C. Or, more often than that, I throw a box or three at the problem as that's cheaper than my time. I just can't recall a problem recently where I've said "Hrm, if this was only 35% faster..." I love the language because of the speed it gives me in translating ideas into functional source code.

    I would really like to help with the porting of some of these packages. The problem is that I don't know where to begin! Sure, I can search the cheese shop, but even then I've got to deal with submitting patches back to maintainers that may or may not even be interested. A while back I suggested via blog entry that I think it would be nice to have a 2-to-3 status page out there so that individuals (like myself) who are willing to help out can work down the check list.

    Overall, I love it! Hopefully it's enough to push the number of available libraries and components to critical mass and spur on a more widespread adoption.

    Though, those of us stuck using RHEL 5 will be forever damned to Python 2.4!
  • "The problem is that I don't know where to begin! "

    Well, start with porting something that you yourself uses. If you don't know how, it's true that the documentation is *very* lacking at the moment. I'm writing an series of articles in The Python Magazine starting in the January issue, those might help.
  • Yeah - RHEL is the bane of New Things, which I think is the point :)

    As for where to begin, I have an idea for an index like you suggest - I need to think about it more and find someone willing to push it out, as I've got a pile of Other Really Important Things to Do. :(
  • I've the same (seemingly endless) pile here, too. Though, what do you have in mind? If I can find a few cycles (and that's a big *if*) I'd be willing to help a bit.

    Generally, anything with the words "Enterprise" or "Proven" in them tend to be technological anchors.
  • cultureanew
    "I would really like to help with the porting of some of these packages. The problem is that I don't know where to begin!"

    FWIW, recently, in search of something useful to do, I thought porting something to Py3k might be fun, or maybe patching something. After poking around python.org, and the bug database, I wandered off, discouraged.

    Manage it and they will code...
  • Why would 3rd party packages, community libraries or projects be in
    the python-core bug tracker? If you want to port something, look at
    http://pypi.python.org/pypi and contact the project owner!
  • YESSSSSSSS!!!!!!
  • Hi !

    Hope this come to life !! Totally +1 from me. Collin went to pyconbrasil and showed us some great things about unladden and i was really impressed.

    I guess if they merge, Python 3 will be the best and new python developers (libs,apps,frameworks) will use it more !

    Long life python, unladden, pypy and all these good things =)
  • rhodium
    I completely agree with you wrt this "can" be the defining carrot to push people to 3k. The moratorium only gives this the needed push in order to show where it "should" go. Really good stuff - I can't wait!
blog comments powered by Disqus