PyCon Australia 2013

Actualizando las aplicaciones Django a Python 3

Jacob Kaplan-Moss  · 

Presentación

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

our next talk is uh from Jacob Kaplan moss there's too many hyphenated surnames and I nearly stuff that up Jacob is the Kobe DFL of Django and a partner at revolution systems where he provides support services around Django and related open source technologies

he also worked where Django was born at world online so today is going to talk to us about Django 1.5 and porting applications to Python 3 please make him welcome hey y'all so I am Jacob carp and moss on top of the other things that graciously listen my

bio I thought I should briefly mention that I've recently switched jobs i'm now the also the director of security at Heroku so among the many other hats that I'm wearing i'm now at a Heroku had on top of that so if anyone wants to talk about

Heroku you can come find me um although i'll probably just tell you to go talk to Kenneth because he's our Python guy and he knows all that stuff all right and that's all I'm gonna say about about my employer that's the obligatory you know

plug let's get into it okay so Jenga 15 shipped roughly six months ago and it was a big deal we had Python 3 support we announced that Django 15 supports Python 3 and we said okay everything's ready it's in place you can start porting your apps

jingle 1.6 is on track to ship in August and 1.6 is really like our official like we really think we're ready we kind of hedged our bets a bit with 15 we called our support for Python 3 experimental the idea being we wanted to give ourselves some leeway

if we needed to make any last minute changes if we discovered issues with our approach we wanted to give ourselves some freedom to break things if we needed to break things turns out we actually got it right on the first try just kind of surprising and so

as of 16 we're basically declaring Python 3 support stable we're saying it's ready for production you can use it in production you know go to town so this talk is about is about that is about our support for Python 3 about what that means for you

and about how you can go about taking advantage of Python 3 so before we start talking about the how there's some sort of natural questions that are going to come up and I think the first one from most people have been using Python for any period of time

is ok but do I actually want to use Python 3 is this actually is this Python 3 thing actually a thing do I want to use it or is it just like Perl 6 this kind of joke that's out there that never is going to actually come to fruition and actually yeah you

really if you like Python you'll love Python 3 really you know all those little things that annoy you about Python the fact that print is a statement so you can't rebind print to log and if you've put print statements in code they go to the console

and you can't like somehow magically make that go out to a log file let's fix in Python 3 the syntax for super that obnoxious super class comma self and I get that right whatever it is fixed in Python 3 I could go on there python 3 is basically Python

2 with all the annoying parts gone it it's hard to explain just how just how nice it is to write code in Python 3 it's it's it's surprisingly pleasant you you sort of have if you've been doing Python for a long time you've internalized

all of these annoyances all of these warts all of these issues and then when suddenly they're not there anymore it's so nice python 3 is way more pleasant than Python 2 i'm the biggest thing though the thing that really tips it over the balance

for us for web developers is that in python 3 unicode is actually a thing it actually works right and this is really amazing right we we don't live in a world where English is the only language that our applications need to support we don't live in

a world where 8-bit ASCII is sufficient to represent every single name of every single one of our users and in Python to actually dealing with real world data dealing with character sets other than a ski starts to just make your head explode Django papers

over some of those issues for you and makes it a little bit easier to deal with but sooner or later you're going to be woken up in the middle of the night with an error message from sentry at a Unicode decode error and you're going to spend a ton of

time trying to trace it down icy heads nodding you know what I'm talking about in Python 3 is basically doesn't happen python3 really really tightens up the rules around how Unicode is is used and represented and as a result if your tests pass your

code will work with any character set it basically pushes the burden of dealing with Unicode issues to a sort of programmer time constraint something the something that you comes up early on in development rather than later it's a basic tenet of programming

right you want to fail early you don't want something that fails once it's in production once it's been running for a while and that forces you to debug through some weird data and Python 3 finally gets that right it's it's totally fantastic

and it it revolutionizes the way that your application deals with sort of international data okay so that's the do you want to use Python 3 the more difficult question is can you use Python 3 there's good news and there's bad news in this in the

sphere the good news is that the Python community is moving a lot quicker now towards a world where pom Python 3 is supported everywhere and that's because of some of the techniques that I'll talk about in a little bit but there's also some bad

news which is that not not everything's there yet the real question about can you use Python 3 or a practical question basically comes down to a question of dependencies if your applications dependencies have been ported then you can use Python 3 and you

should but if they haven't then you have to do a sort of complicated calculus of okay well can I can I switch dependencies and use something else instead can I take the time as part of my development effort to port something else to python 3 or do I just

have to kind of throw up my hands and use Python 2 so let me go through some of the like big dependencies and talk about the current state where we are right now in terms of Python 3 support so the first big problem that you're going to face when you run

into Python 3 is your choice of databases and whether or not your database is supported by by Python 3 or by Django together so if you use postgres you're fine and we all use postgres so I'm just going to move on right seriously uh it's just switch

to postgres you'll be so much happier sequel lightworks my sequel is kind of in a weird state there is a Python 3 compatible my sequel connector buying a binary that Oracle puts out but there are there are licensing concerns I'm not going to shave

that yak here on stage come talk to me later if you're interested about the state state of the art here but basically as it stands we the Django sort of cork committers cannot recommend that you use Oracle's my sequel connector in your application

it may work and you may want to try it if my sequel is a hard requirement but we can't recommend that you do that because of some licensing concerns on our end and if you're a nerd and want to talk more about that you can find me afterwards and I don't

actually know the state of Oracle support I do know that CX Oracle the the Python binder has been ported to python 3 our CI server doesn't yet run Django's tests against oracle and python 3 so I don't actually I can't give you hard data on

that I I believe that it works at least as well as Python to support does but I'm not a hundred percent sure they're so I've put the little question mark there so depending on what database you're using and depending on your flexibility and

switching databases you may or may not be able to use Python 3 once you've answered that question you'll probably want to be talking about deployment the good news is that you have a lot of good options when it comes to deployment the bad news is that

the most popular option which is gonna corn and G event at least that's that's what seems to me from sort of surveying what people are doing out there i doesn't really work that well there's a Python 3 branch of G event but it it's been

unstable in my testing however mod wsgi has supported Python 3 for a long time since before we did and uwsgi also works on Python 3 and 4 low-traffic the various gun the gonna corn sync workers which are actually surprisingly fast work pretty well so you've

[ ... ]

Nota: se han omitido las otras 4.388 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.