Latest / Talk Python To Me / #6: Requests, PyCon, and Python's future
Transcript
- 0:00Talk Python To Me, episode number six, with guest Kenneth Wright, recorded Friday, April 17th, 2015.
- 0:09Hello and welcome to Talk Python To Me, a weekly podcast on Python,
- 0:39the language, the libraries, the ecosystem, and the personalities.
- 0:42This is your host, Michael Kennedy.
- 0:44Follow me on Twitter where I'm @mkennedy,
- 0:47and keep up with the show and listen to past episodes at talkpythontome.com.
- 0:51This episode will be talking to Kenneth Wright about requests, the package, API design, PyCon, and more.
- 0:59Hello, Michael here.
- 1:02I've got a couple of news items for you.
- 1:04First, thank you to everyone who contacted or mentioned the show on Twitter,
- 1:08where we're at Talk Python.
- 1:10I really appreciate the feedback and suggestions.
- 1:12It's also a nice way to let others know about the show, and it makes a big difference for us.
- 1:17Next, if you're listening to the show and you have not yet subscribed, please do.
- 1:21Open up your favorite podcatcher and search for Python.
- 1:24The show should be right near the top.
- 1:26If it isn't, send me a note and I'll try to fix that.
- 1:29How about a t-shirt?
- 1:31I think I have a really cool design for a Talk Python themed t-shirt.
- 1:35If there's enough interest, I'll actually create it.
- 1:38Visit talkpythontome.com, look in the footer, and click t-shirt,
- 1:43or just visit talkpythontome.com slash home slash shirt and press the button.
- 1:49Finally, I want to say thank you to Tobias, Macy, and Chris Patty.
- 1:53In some crazy coincidence, the Python community was without a proper podcast for almost a year.
- 1:59Then Tobias and Chris and I independently set about creating new podcasts.
- 2:04And with all the setup and scheduling and a million little items it takes to get a podcast off the ground,
- 2:10we ended up releasing in the very same week.
- 2:13Amazing.
- 2:14Check out their show called Podcast Under Under a Knit at podcastinit.com.
- 2:19Now, let's get on to speaking with the amazing Kenneth Reitz.
- 2:23Kenneth, welcome to the show.
- 2:26Thank you for having me, Michael.
- 2:28Yeah, this is great.
- 2:30You've built some amazing open source packages, and I'm glad we got a chance to share that with the world.
- 2:35Absolutely.
- 2:36I'm really glad to be here.
- 2:38Cool.
- 2:39So before we get into sort of modern day, what are you working on and so on,
- 2:43I think people find it really interesting to see how everyone has come to Python
- 2:48and got started in this whole community.
- 2:51So maybe you could just tell me a bit about how you got started in Python and what's your story?
- 2:55I started doing Python when I was in undergrad.
- 2:58I went to George Mason University, and they had a Python class.
- 3:02And I had already been doing a lot of programming languages throughout my life.
- 3:06You know, since I was a young kid, I was learning like basic and C and play with Pascal and stuff like that.
- 3:11And Python really attracted me as a language.
- 3:13And so I had dropped out of school shortly thereafter and just kind of started doing it full time.
- 3:19And here I am.
- 3:19That's awesome.
- 3:21So you're really glad you just took Python and ran with it, huh?
- 3:24It's working out well?
- 3:25Yeah, absolutely.
- 3:26I was doing PHP for a while, and I did a little bit of Java and all kinds of stuff.
- 3:31But Python has really resonated deeply with me and what I'm doing.
- 3:34Yeah, that's cool.
- 3:36So the reason that I reached out to you, the sort of thing that I know you for, if you will, is your request packages, which is sort of an HTTP client library for Python.
- 3:45Maybe start, I suspect a lot of people know about requests, but not everybody.
- 3:51So maybe give me like the 30-second elevator pitch.
- 3:53Like, what's wrong with URL lib?
- 3:55Why did you create this request package and go with that?
- 3:58Yeah, so request is called HTTP for humans.
- 4:01And originally when I created it, it was not called that.
- 4:04It was actually called HTTP for Python that doesn't suck.
- 4:07It was a much more negative title.
- 4:10And it kind of evolved as I was going along.
- 4:13And I decided I didn't want to be putting down other projects, but I wanted to be building up the community.
- 4:17So I called it HTTP for humans.
- 4:19And effectively the pitch is that if you're, you know, the internet is basically the way we communicate.
- 4:25You know, it's like everything that we do usually goes over the internet when we're building tools today.
- 4:30You know, the entire world revolves around the internet.
- 4:33And so making calls to the internet with Python should be as simple as the print statement.
- 4:39And if you use the built-in tools that come with Python, it's tremendously difficult.
- 4:43So I built requests to make it really great.
- 4:47And I believe I succeeded.
- 4:48Yeah, I think you did a really fine job.
- 4:51And, you know, whenever I've needed some sort of HTTP client for Python, I definitely use requests.
- 4:55I mean, you know, if I think what I have to write in order to do an authenticated request with URL lib, you know, it's ridiculous.
- 5:04The default password or password manager with a default realm?
- 5:07Yes, exactly.
- 5:08So you have to specify the domain or whatever it is.
- 5:11Take an opener and then install the opener.
- 5:13And then it's a nightmare.
- 5:14It's a total nightmare.
- 5:15So, yeah, it's definitely a breath of fresh air.
- 5:18Thank you.
- 5:19So, you know, building libraries like that, you probably spend a lot of time thinking about APIs and what makes a good API.
- 5:26Yeah.
- 5:27Request is kind of like my – if people ask me what my favorite libraries are, I usually answer request is my favorite one.
- 5:33Because it is.
- 5:35I've put a lot of thought and design into the way it works.
- 5:38And it is kind of like my personal, like, you know, totem of good design.
- 5:44And, yeah, there's a lot of – I'm very opinionated about certain things in Python.
- 5:48Actually, PyCon – Raymond Hediger just did a great talk at PyCon called Beyond Pep8.
- 5:54And he kind of got into a lot of these things, which was – it's all basically about, like, taking the basic data model in Python.
- 6:01And, you know, like, you can make an object behave in any number of ways and using properties and stuff.
- 6:07And I think it's a really good starting place for someone that wants to know how to build good Python code.
- 6:13Yeah.
- 6:13Okay.
- 6:13That's really cool.
- 6:14And, you know, all those shows are recorded.
- 6:16And we'll talk about that a little bit later.
- 6:17So I recommend people go check that one out.
- 6:20And just for the listeners who maybe are catching this later or got the recording after a few weeks later, you know, this is April 21st.
- 6:28And PyCon was – it was like a week ago?
- 6:30Yeah.
- 6:31I just got back two or three days ago from PyCon.
- 6:34Yeah.
- 6:34It was last week, wasn't it?
- 6:36That's right.
- 6:36Yeah.
- 6:37Well, I stayed extra long for the sprints.
- 6:38So it was good.
- 6:40I was there for, like, 12 days in total.
- 6:41It was ridiculous.
- 6:43Amazing.
- 6:43Amazing.
- 6:43Amazing.
- 6:44So before we get to that, you know, can you kind of say a few comments about what you think makes good API design?
- 6:51I mean, obviously, Request has it.
- 6:54But what do you think, like, the essential ingredients are?
- 6:56Well, so I have a litmus test that I pitch people.
- 6:58And it's basically that if you have to look at the documentation every time you use the module, then you should either find a new module or build a new module.
- 7:05That's a good plan.
- 7:07Yeah.
- 7:08Good recommendation.
- 7:09It's, like, surprisingly difficult when you're using code.
- 7:11Like, if you have to...
- 7:12I'm not saying, like, you know, if you pick it up for the first time in months, then looking at the docs.
- 7:16But, like, there are certain code bases where, like, you just have the docs and you're looking at them more than you're looking at the code.
- 7:22And to me, that's not, you know, that's a testament to an unergonomic design.
- 7:28Yeah.
- 7:29Or a really hard problem space, one of the two.
- 7:31Right.
- 7:32It could be a super hard problem space.
- 7:34But...
- 7:35But even in those cases, there's, you know, you can build a layered API and, you know, you can have a nice human layer as well as a low-level one.
- 7:42Absolutely.
- 7:43Just because your library might do 100 things, there's probably, you know, what, two or three very common use cases.
- 7:49Maybe there should be some, like, higher-level abstraction that you use for that.
- 7:53Precisely.
- 7:54And then you dig down.
- 7:55You know, I'm thinking of things like we just spoke to Mike Bayer from SQLAlchemy.
- 8:01Very nice.
- 8:01And with SQL...
- 8:02Yeah, which is a great conversation.
- 8:04And, you know, with SQLAlchemy, you've got two, literally two layers you can think of, right?
- 8:09There's, like, the SQLAlchemy core, which is purely about data access.
- 8:12Then there's the ORM, which is kind of like the, hey, let's keep it a little bit easier, but you have maybe less control over the performance.
- 8:19Or so on.
- 8:19It's funny you mention that, because I actually want to work on a new project that's like SQLAlchemy for humans.
- 8:24But we'll see how it goes.
- 8:28Yeah, excellent.
- 8:29Excellent.
- 8:29So before we move off of requests, let me ask you just a couple more questions on it.
- 8:34Are there, like, really notable users or sort of, like, famous use cases that you can talk about?
- 8:40Yeah, well, it's basically, it's quite ubiquitous.
- 8:44Basically, if anyone's doing Python and HTTP, they are using requests.
- 8:47The one that I'm the most proud of is Amazon uses it for their internal API tools.
- 8:53So everything that runs EC2 and S3 and all of AWS, every single API call goes through requests, which is astonishing, because that means, like, it's powering the entire internet.
- 9:03Yeah.
- 9:04And you, in some way, you are, like, a layer beneath so much of the internet.
- 9:08That's really cool.
- 9:09Yeah, I'm really proud of that.
- 9:11Speaking of APIs, you know, one of the things that really puts external pressure on APIs is the whole async programming model.
- 9:19So, you know, traditionally with things like Twisted, but, you know, more modern with AsyncIO, does requests have any support for that?
- 9:29Or what do you think about, you know, APIs in general adapting to these async stories?
- 9:34So the old way, sorry, like, kind of the current best practice way of doing it is using gevent.
- 9:39And what that does is it monkey patches the entire standard library.
- 9:44And it adds basically callbacks throughout every piece of blocking code in the standard library, in theory.
- 9:53I mean, that's what it's designed to do.
- 9:55It doesn't do a perfect job, but it gets the job done most of the time.
- 9:58And then what you do is you have an event loop, and you say, like, instead of, like, you know, you have a function that's, like, go get this HTTP request with requests, and that blocks.
- 10:07You know, it's, like, a very, like, blocky process.
- 10:10But if you do it with gevent, you can just say, like, run 100 of these, and it does them all concurrently, and it comes back.
- 10:15And it works really well.
- 10:16Then in Python 3, I think in 3.2 they added it.
- 10:20They added this new library called AsyncIO.
- 10:23And it's Guido's, it used to be called, known as Tulip.
- 10:26And it is the new asynchronous way of interacting with, just, you know, doing asynchronous work, especially over the network.
- 10:33And it's still very new.
- 10:35It's what is considered to be a provisional package within a standard library, which means that it is not officially done.
- 10:43So there's, like, a small core that's still being iterated on, and then there's going to be, like, an official HTTP client after that.
- 10:50And I don't necessarily think that will replace the usage of requests or these blocking-style services, but it's too early to tell, I would say.
- 10:58But right now you can use gevent, and, like, you get the best of both worlds, and it works really well.
- 11:03Yeah, that's, okay, that's really cool.
- 11:05I don't think every API or every use case needs to use AsyncIO.
- 11:09I mean, it's one of these special case scenarios.
- 11:13I'm running a web server, and I want to support, you know, 20,000 requests on this machine, right?
- 11:19Maybe you need to think about async programming.
- 11:21But if you're just writing, like, a basic web scraper, then maybe you do, maybe you don't.
- 11:25It depends what you're up to.
- 11:26Yeah, I mean, you can always scale as long as your performance is predictable.
- 11:30And unfortunately, when you're using something like gevent, it makes things a lot less predictable.
- 11:34But, you know, it depends on what you're doing, really.
- 11:37It's one of those things where you just have to try it and see if it works for your project.
- 11:42A lot of times, your code isn't compatible because of different C dependencies, because
- 11:45that always blocks.
- 11:45And, you know, it's kind of like this big hairball you're getting yourself into.
- 11:49But, you know, if you have the right type of code and you use gevent, you can, you know,
- 11:55come close to, like, node performance benchmarks and go.
- 11:58It's really fantastic.
- 11:59Yeah, that's really great.
- 12:00Michael here.
- 12:08Thank you so much for listening to and spreading the word about Talk Python TV.
- 12:13I'm still looking to line up stable corporate sponsorships, but I wanted to tell you about
- 12:17a community-based campaign I'm launching to allow listeners to directly support the show.
- 12:21We are running a Patreon campaign.
- 12:23Consider supporting us today at patreon.com slash mkennedy.
- 12:26And thanks for listening.
- 12:27Okay, so like we were saying before, you just came back from PyCon.
- 12:40And you, it's amazing.
- 12:41You spent 12 days there.
- 12:42You've been, like, completely immersed.
- 12:44What are your thoughts?
- 12:44On the conference itself?
- 12:46Yeah, just the whole experience and what was the vibe of Python this year and so on.
- 12:51Well, so PyCon is kind of like my way of measuring the year every year.
- 12:56Like, you know, every year, like, most people, like, think of the new year as the start of
- 13:00their new year.
- 13:00But for me, like, PyCon is kind of like where I, like, you know, sit down and think about
- 13:05my life and all this stuff.
- 13:06And it's great because, like, I go to all these tech conferences all the time for work and speak
- 13:11at these conferences and events and I hang out with all these people everywhere.
- 13:14And I get to see almost all of them at PyCon.
- 13:16So for me, it's a very social event.
- 13:18It's a very, it's very work-oriented, but it's also very personal.
- 13:22And it's just kind of like, you know, this most intense week of my life.
- 13:25And I had a really great PyCon.
- 13:28I'd say this is my best PyCon so far.
- 13:30The energy of the whole thing was really good.
- 13:33There were some things that were a little different this year, even from last year, which was also
- 13:37in Montreal.
- 13:37I don't know.
- 13:40I liked it, though.
- 13:40It was good.
- 13:42To me, I personally spent a lot more time interacting one-on-one with people instead
- 13:47of, like, doing these big group talks, like kind of normally happens where you get, like,
- 13:5020 people in a circle and everyone's talking.
- 13:52I used to do that constantly.
- 13:54And then this year, I spent a lot more time, like, you know, spending time with the people
- 13:59I wanted to see.
- 13:59And that seemed to be really beneficial to me.
- 14:01Yeah, that's really excellent.
- 14:03Some of my favorite conferences, I've hardly gone to any of the talks.
- 14:06It's just you kind of go there and you spend your time with the people and in the environment.
- 14:11And, you know, maybe you see the talks, maybe you don't.
- 14:13Exactly.
- 14:13At PyCon, that's known as the hallway track.
- 14:15Yeah, awesome.
- 14:17How many years have you been going?
- 14:19Excuse me.
- 14:21Let's see.
- 14:22This was, my first one was 2011.
- 14:24So, I guess this is my fourth PyCon.
- 14:26Excellent, excellent.
- 14:27Yeah, I couldn't go this year.
- 14:28My wife was also traveling and we have small kids and we'd be in trouble if we both left
- 14:32town.
- 14:32Well, there's always next year.
- 14:33Yeah, and it's coming to my hometown, so it's looking good.
- 14:36Yeah, that'll be great.
- 14:37Brandon Rhodes is running this year, so I'm really excited to see what he,
- 14:41what he does to it.
- 14:42Yeah, that'll be fantastic.
- 14:43So, can you tell me what some of your, you know, speaking of not going to the talks and
- 14:48then asking you the opposite question, can you tell me what some of your favorite sessions
- 14:52or topics that were covered at PyCon?
- 14:54Well, I didn't go to any talks.
- 14:58Awesome.
- 14:59So, you really enjoyed the hallway track.
- 15:00That's fantastic.
- 15:01Yeah, I have almost a no-talk policy because I go to, I go to a lot of conferences and they
- 15:05all kind of blur together eventually.
- 15:06But, and especially at PyCon, they're all already up online.
- 15:09Like, you can watch them now.
- 15:11And so, I just kind of, you know, I do that.
- 15:13And I, I'm there to see the people.
- 15:15But I have watched a few already.
- 15:17And I really enjoyed, Jacob Kaplan Moss, who is one of the runners of the Django
- 15:22project.
- 15:22And a coworker of mine did a really great keynote that I enjoyed, about just kind
- 15:28of like the diversity in tech, problem in that space.
- 15:31He, he went up on stage and was like, everybody, I'm a mediocre programmer.
- 15:35And I was like, that's pretty cool.
- 15:37And I was thinking like, if I was to do that talk, I think I would do the opposite.
- 15:40I'm like, I'm an amazing programmer and so are all of you.
- 15:43But, but, yeah, it was a good talk.
- 15:47And so, that's the only one I think I've really sat down and watched.
- 15:49Although I watched Raymond's talk as well on beyond pepe.
- 15:52And that was, I think, fantastic for, cause people, I've never seen it so well solidified
- 15:57before how to write good Pythonic code.
- 15:59So, I'd recommend checking that out as well.
- 16:01Okay.
- 16:02Yeah.
- 16:02Those, those both sound really awesome.
- 16:03So, because I couldn't go, I kind of, you know, YouTube was my connection to PyCon this
- 16:09year.
- 16:09So, I'm like, all right, well, let me go through and sort of make a playlist for myself and what
- 16:14I think, you know, at least just reading the descriptions seems like, you know,
- 16:19kind of essential or the real valuable stuff.
- 16:22Now, you know, not to disparage anybody else's stuff that's not on the list or whatever, but
- 16:26these are just the ones that jumped out at me.
- 16:27Right.
- 16:28Yeah.
- 16:28So, on YouTube, I made a playlist.
- 16:30You can find it at bit.ly slash PyCon 2015 MK, all lowercase.
- 16:38And I think, how many videos do I have there?
- 16:40I've got 29 videos, apparently.
- 16:42Nice.
- 16:43Yeah.
- 16:44And so, you know, some of them that I thought were pretty cool was there's one called Bytes
- 16:48Inside the Machine, Inside the CPython Interpreter.
- 16:51And that's by Allison Captur.
- 16:53And I thought that was really cool because a lot of time, you know, you spend time so high
- 16:58in sort of the Python code, like looking down at actually what happens when you run it.
- 17:03I thought that was pretty cool.
- 17:04Andrew Baker did one on demystifying Docker.
- 17:08Oh, yeah.
- 17:09And I think Docker is going to be massive.
- 17:11You know, it's already kind of massive, but I think it's just at the beginning, you know?
- 17:15I agree.
- 17:16Yeah.
- 17:17And so, I think understanding Docker is going to be really important if you're doing anything
- 17:21involving like a server.
- 17:22Which?
- 17:23It's pretty much everyone.
- 17:25Not everyone.
- 17:26There's plenty of people that just run, you know, scripts on their machines.
- 17:30But for the most part, I think people need to understand that.
- 17:33So, that's pretty cool.
- 17:33And then Gary Ward did one on how to write reusable code, which sounds a little bit like
- 17:37beyond PEPT-8.
- 17:38Yeah.
- 17:39Yeah.
- 17:40And let's see.
- 17:41A few more.
- 17:41Ryan Kelly did one on PyPy.js.
- 17:43Oh, I didn't hear about that.
- 17:45That sounds amazing.
- 17:46Yeah.
- 17:46Doesn't that sound cool?
- 17:47Like, you know, running Python.
- 17:49Is this a JavaScript interpreter?
- 17:54I don't remember exact.
- 17:56I think it.
- 17:57I suspect it is.
- 17:58Because PyPy is, in addition to being a Python interpreter, it's also a platform for building
- 18:03other interpreted languages.
- 18:04Right.
- 18:05It may well be.
- 18:06So, maybe it's running.
- 18:07Yeah.
- 18:07I actually should stop talking because I now know.
- 18:10I've now told you as much as I know about it.
- 18:11Other than watching it because that one I haven't seen.
- 18:14You know, I'd like to get your thoughts on one that Guido did.
- 18:17Just the topic, not because I know neither of us have seen it yet, is type hints.
- 18:21Oh, yes.
- 18:22I've talked to Guido about type hints.
- 18:24What do you think about type hints?
- 18:25I don't care about them.
- 18:27But I know he's really excited about them.
- 18:29And it's interesting.
- 18:31So, it seems like those are being built to serve this particular market that I am very
- 18:35disconnected from.
- 18:35And I think that the people that are involved in the core development of Python are connected
- 18:39to.
- 18:40And it seems to be like these people that are like building compilers and like, you know,
- 18:44they're like taking Python code and turning it into something else for like optimization
- 18:48and stuff.
- 18:49And I think that that's the idea behind type hints.
- 18:53I think that's like a use case.
- 18:55It's definitely a use case.
- 18:57Another one that jumps to mind is if you're building editors like the PyCharm guys.
- 19:01Yeah.
- 19:02And that seems just really odd to me to build, you know, to build language features around
- 19:08that.
- 19:09But because, but I'm not like, I'm not in that space.
- 19:12So, I don't know what the real motivation is.
- 19:15But it just seems a little odd to me.
- 19:16And everyone I talk to also doesn't care about type hints.
- 19:20But it's also one of those things that I don't think you'll need to care about if you're not
- 19:23going to use them probably.
- 19:25Yeah, I suspect that's right.
- 19:26You know, if you're coming from Java or C# or some other typeful language, that might
- 19:31convince you to make the leap.
- 19:33Yeah.
- 19:33Whereas if you've been doing Python for 10 years, you're like, we don't need this, you
- 19:37know?
- 19:38Yeah, I'm definitely in a different camp than Guido is.
- 19:40I'm very much, I love Python 2.7.
- 19:42And I feel like I could use it for the rest of my life.
- 19:45I'm planning on like, you know, fully embracing 3 when everyone else does.
- 19:51And so, there's a lot of, you know, like all this new development on these type hints and
- 19:55stuff doesn't sound as exciting to me as like, making sure that we have a way to like ship
- 19:59like standalone binaries.
- 20:01I feel like that would be a really great use of our time.
- 20:03I'm not saying that Guido shouldn't be working on this.
- 20:06Like, he should work on whatever he wants to work on.
- 20:08And I'm really excited that he's putting the work into this.
- 20:10But I hope other people, you know, don't stop working on other things because of it.
- 20:15And I don't think they will.
- 20:16That's not happening.
- 20:16I was at the Language Summit this year.
- 20:18And we had a really great conversation about the next year of Python.
- 20:21And there was a lot of talk.
- 20:23Guido did one on type hints.
- 20:25There's a lot of really great stuff that kind of came up.
- 20:28Okay, that's cool.
- 20:29Can you talk about what else was at the Language Summit?
- 20:31Let me think.
- 20:33I was only there for the second half.
- 20:34I did a talk on requests.
- 20:35And because everyone is really interested in adding it to the standard library.
- 20:40So I did a talk about the pros and cons of that.
- 20:43And basically stated that requests is a critical piece of infrastructure for the Python community.
- 20:49Because pip relies on it.
- 20:51And like pip ships with Python.
- 20:52And, you know, it's like the most popular Python package there is.
- 20:57So, and I have security updates.
- 21:00You know, when there's like a CVE that's released for HTTP and OpenSSL and stuff, we have to make changes.
- 21:06And, you know, Python has a 16-month release cycle.
- 21:08And we've released a version by maintainers in like 12 hours.
- 21:14So there's a big difference there.
- 21:16So if requests was to go into the standard library, it would be, I think, irresponsible.
- 21:20So we decided together as a group that requests is going to be officially recommended in the Python documentation.
- 21:27Instead of going into the standard library.
- 21:31Which seems like a good compromise.
- 21:33Right.
- 21:34That makes a lot of sense.
- 21:35And, you know, HTTP being such a critical but vulnerable layer as well.
- 21:41And morphic layer as well.
- 21:42What, sorry?
- 21:44Amorphic layer as well.
- 21:45It changes over time.
- 21:46Yeah, absolutely.
- 21:47It's definitely changing.
- 21:48And if that needs to be fixed, it needs to be fixed now, not in a year.
- 21:54So that's really interesting.
- 21:55Yeah, I think that was a good takeaway.
- 21:57It seems like a good takeaway.
- 21:58Cool.
- 21:59Well, I guess one more that I thought was worth calling out.
- 22:02And maybe we'll do a show on this one.
- 22:03It's a guy named David Beasley.
- 22:05Yes.
- 22:06Did one on modules and packages.
- 22:09Oh, very nice.
- 22:10Did a three-hour workshop on it.
- 22:13And you think, what is there to know about modules and packages for three hours?
- 22:16But actually, there's a lot of really interesting stuff about, like, maintainable sub-imports when you're building large packages.
- 22:24And all sorts of cool stuff that I think is actually a lot of people would get a lot out of.
- 22:28So that's also on that list of videos.
- 22:31Yeah, David Beasley always does amazing work.
- 22:32He's kind of crazy.
- 22:34Yeah, it was really good.
- 22:36So that was fantastic.
- 22:39So what else would you like to get out into the community about Python and just let people know while you got a chance?
- 22:46Let me think.
- 22:47I've been very concerned for a long time about the adoption of Python 3.
- 22:51And I still am.
- 22:52And we had some discussion about that at PyCon as well.
- 22:55And it's interesting.
- 22:56It seems as though on certain platforms, like where I work at Heroku, we have about a 10% in the last month or so deploy rate for Python 3, which is really surprising.
- 23:06And it seems to me as though this, and it's also, if you look at the cheese shop numbers, Python 3 is starting to get a little bit more usage.
- 23:15You know, it's still extremely minimal and far behind what we want.
- 23:17But the needle is moving.
- 23:19And it's really fascinating because the only thing that I can tell has changed is that Django, when they made their last release, they officially, they just used Python 3 by default.
- 23:28And that seems to have a tremendous impact on people, on users of the language in general.
- 23:34Just having literally the quick start for Django in all the documentation is just Python 3 by default.
- 23:39So I think that's really interesting.
- 23:41And I think that there's a lot to learn about that and just kind of think about that and just be like, you know, maybe if I share code samples with people, they should be Python 3, not Python 2.
- 23:51You know, maybe that'll help make a big difference.
- 23:54You know, if we just like shift our default mode, maybe it'll get us over this hump.
- 23:59Because I am concerned about the future of the language.
- 24:01I think that we have a big marketing problem.
- 24:03I think that there's this product that's being built that no one wants.
- 24:06And so no one's using it.
- 24:07And I think that it's just all about getting on the same page.
- 24:11Yeah, I think that's a really good idea.
- 24:14I mean, even if it's just going to blog something and put up a code snippet, if you started making that Python 3 more frequently, that would probably send some kind of signal to the world, you know?
- 24:22Yeah, it's just so interesting to see.
- 24:24I mean, like there's a, the needle is like actually moving.
- 24:26And it is because Django changed their docs to use Python 3.
- 24:30And that's just, that blows my mind.
- 24:32That's not, it can't be that easy.
- 24:36Well, nobody would have, you know, thought that would make the difference.
- 24:40But, you know, sometimes things are unpredictable, right?
- 24:43Exactly.
- 24:43Yeah.
- 24:44So I'm all in favor of us.
- 24:45You know, I've been for a long time.
- 24:47If you talk to me in private, I'd always say that I'm a Python 2 life, Python 2 user for life.
- 24:53And I do kind of feel that way.
- 24:54But the reality is that the Python community is valuable enough to me that I don't care what I'm using as long as we're all using the same thing.
- 25:01So I think that we should all just kind of embrace the change and just see what happens.
- 25:07You know, I think when you look at the actual code, sort of like modern Python 2 versus Python 3, there's not that much of a difference.
- 25:14It's kind of the libraries or the packages that you want to take along.
- 25:18Like, oh, this doesn't support Python 3.
- 25:20Well, this project isn't using Python 3.
- 25:22Yeah, it definitely depends on the style of project you're doing, too.
- 25:25So if you're doing something that deals with bytes as text, which I do a lot because I work with HTTP, then Python 3 is the worst language in human history, basically.
- 25:36Yeah, it's true.
- 25:38Because the string stuff is really pretty different, right?
- 25:41Yeah.
- 25:41So if you have a byte string and you can't do anything with it anymore, it's just like a byte array of bytes, you know, of integers.
- 25:51And so if you can't do, like, formatting and stuff, I think they added formatting back, actually, I think in 3.4.
- 25:57But they didn't add the .format method.
- 25:59They did the percentage, the modulus override, which is ridiculous.
- 26:04But so you can format strings again.
- 26:06But still, you can't parse them very easily.
- 26:08You can't work with them very easily as text.
- 26:10And to me, Python 3 makes a lot of sense in a world where everything is Unicode, but we don't live in that world.
- 26:16You know, because, like, when you're sending stuff over the internet, when you're writing it to disk, when you're sending an email, it's all actually bytes.
- 26:24And so I really enjoyed the flexibility that Python 2 had in that.
- 26:29And that was, like, my favorite part of the language.
- 26:31And they kind of took that away from me.
- 26:32So I am de-incentivized to use 3 personally.
- 26:37And if you look at, like, Armin Ronecker, the guy who wrote Flask, he writes really detailed blog posts about the same problem.
- 26:43And it sucks.
- 26:45But at the same time, like, if you – usually when you're interacting with that stuff, you're dealing with libraries.
- 26:50You know, we deal with it because we're library authors.
- 26:52So if we solve the problem, then it's okay for everybody else.
- 26:55Right.
- 26:56You guys are basically the firewall to that problem, right?
- 26:59You live literally at the network layer, both of you.
- 27:02And by the way, we're going to have him on and do a show on Flask.
- 27:04Oh, fantastic.
- 27:05And other topics as well pretty soon.
- 27:07I'm looking forward to listening to that.
- 27:08Yeah.
- 27:09But I think, you know, you probably feel it worse than a lot of people because you live at the network boundary.
- 27:14Yeah.
- 27:14To me, adding Python 3 to requests was, like, one of the most painful things I've ever done as a programmer.
- 27:20Definitely one of the most frustrating, if not the most frustrating.
- 27:23But I learned a lot from it, too.
- 27:25It got better in some ways.
- 27:27Like, in Python 2, it was admittedly unclear if you were dealing with bytes or Unicode.
- 27:34So before in requests, if you got back an HTTP response, and if I could decode it to Unicode, it would just be Unicode.
- 27:43The content of it would be, like, response.content.
- 27:48And if it was Unicode, it would be Unicode.
- 27:50If it was bytes, it would be bytes.
- 27:51And it would, like, change.
- 27:52And then when I went to 3, that, like, that API doesn't work anymore.
- 27:56It's just not possible.
- 27:57So you had to split them up.
- 27:58So now there's .content, which is always bytes, and there's .text, which is always Unicode.
- 28:02And that is a superior API design and something I should have done before.
- 28:06And using Python 3 helped me design it better.
- 28:09So I do think it's a good, you know, I think that there's a lot of benefits to using 3.
- 28:14I think that, you know, there'll be a lot less data loss errors that people have.
- 28:18But at the same time, it's, like, really fucking frustrating.
- 28:23Yeah, it makes a lot of sense.
- 28:24So how do you think Python 3 would look different if it was 90% use case?
- 28:30Like, do you think there would be different pressure applied to it?
- 28:35Or would it just be slightly more polished?
- 28:37Do you mean if I...
- 28:40So, like, with requests, I say that...
- 28:42Well, you'll imagine, like, we could snap our fingers and tomorrow, like, 90% of Python projects that are active today are using Python 3.
- 28:49Gotcha.
- 28:50What would that change?
- 28:51What would the world look like?
- 28:52Do you think Python 3 would be changed by that?
- 28:56Or do you think people would just adapt?
- 28:57Like, are there things in Python 3 that just haven't had enough, you know, we need it this way pressure put upon it?
- 29:03Oh, I see what you're saying.
- 29:05I feel like it is possible for us to have a 90% adoption rate now.
- 29:11It just takes a lot of time.
- 29:13And really the problem is that Python 3 right now isn't attractive enough to incentivize people to rewrite all their code to work with 3.
- 29:22If you have existing code, you know, you're not going to...
- 29:24You have to change it in order to get it to work.
- 29:26And so Python 3, I do think to get to that point, we either need a lot of time or we need to incentivize users by making something really attractive that looks really nice.
- 29:38You know, there's been some talks of, like, what if we remove the gill?
- 29:40Would that be attractive enough?
- 29:42You know, and stuff like that.
- 29:44There's a lot of different options.
- 29:45And none of them are very clear at this point.
- 29:48Right.
- 29:48That's a really interesting idea.
- 29:50And I do think you need, like, the killer reason.
- 29:52Yeah.
- 29:52It forced a lot of people to go to the trouble of actually changing code.
- 29:56Like, it's one thing to say, we'll do new projects at Python 3.
- 29:59But, you know, how many new projects do people do versus, like, we've had this whole infrastructure for 10 years and now.
- 30:05It's so funny.
- 30:06I went to go do that recently and it was just so frustrating.
- 30:09I think I was using Flask.
- 30:12I don't think it has.
- 30:12They support 3, but I don't know if it's, like, proper 3 support.
- 30:16There was something I was running into.
- 30:17And it was just, like, I wanted to throw my computer out the window.
- 30:20You know, and it's, like, everything works great with 2.
- 30:23Why should I have to deal with this?
- 30:24So I don't.
- 30:24And that's what everybody does because they don't.
- 30:26So it'll be interesting to see what happens.
- 30:29I have faith that the community will, you know, whatever happens is what is intended to happen.
- 30:34You know, it'll be for the best.
- 30:35Yeah.
- 30:37I agree.
- 30:38I think it's just a little unhealthy that there's such, like, the forward progress is kind of being put on the language on 3.
- 30:45But a lot of the real work is still being done in 2.
- 30:48And it just seems like that can't be a real positive thing.
- 30:51Yeah.
- 30:52And to me, the biggest problem is that we stand up and preach, you know, PEP20, the Xenopython, all the time.
- 30:57And one of the best ones in there is there should be one and only one obvious way to do it.
- 31:01And you go to python.org and you want to go download Python.
- 31:05And you have to pick Python 2 or Python 3.
- 31:08And it's like, what?
- 31:09No.
- 31:11You know, like, it's confusing for new users.
- 31:15And so you have a lot of new users that are using 3.
- 31:18And they're actually really adamant about 3.
- 31:20So if you go onto, like, Reddit or Hacker News and you see anything about Python 2, you'll have all these people that are, like, bashing them and being like, why aren't you using 3, man?
- 31:29That's so old.
- 31:31And it's like, who are these people?
- 31:32Because I go to conferences and I meet all the Python developers that go to conferences.
- 31:35And those people aren't at the conferences.
- 31:37And it took me a while to figure it out.
- 31:39It's the new people.
- 31:40Because when you're new and you're learning to code and it's like your hobby, you're, like, online all day, like, typing on Hacker News and on Reddit, you know?
- 31:47So there's, like...
- 31:49If you're not busy, you can go complain.
- 31:50Yeah, exactly.
- 31:51So, you know, the people who work for companies, they're using 2, you know?
- 31:54But, you know, the new kids are starting to use 3.
- 31:57And I would like for that to be the same community and not two different communities.
- 32:02And it appears as though at this time there are two different communities.
- 32:04So I'm just...
- 32:05I just want us to be unified instead of separated.
- 32:08Yeah.
- 32:09Well, that makes sense.
- 32:09I mean, if you're starting a new project, you have the flexibility and whatever.
- 32:13But if you're working on older technology that, you know, was written before Python 3 even came out, there's maybe no choice at all, right?
- 32:20It's...
- 32:21That's what you're going to be using.
- 32:22So a lot of the companies I visit, they're still Python 2 as well, of course.
- 32:27Yeah.
- 32:27I don't know any major companies that are using 3 at all, but I'm sure there are some.
- 32:31Yeah.
- 32:33There's a few I've talked to, but I can't...
- 32:36I don't want to say it because I might get it wrong and conflate them with other companies I spoke to.
- 32:40But yeah, there's a few, but you're right.
- 32:42But it's not a large portion.
- 32:44Yeah.
- 32:44But I'm hopeful that everything will unfold as it's supposed to.
- 32:49Did you guys talk about that at the Language Summit?
- 32:51It was not brought up as much as you'd think.
- 32:54It was more...
- 32:54So there was one great talk.
- 32:56It was by Jacob, again.
- 32:59And he went up on stage and he was kind of just showing some numbers that he has access to on different adoption rates.
- 33:08And it was interesting.
- 33:10So basically what he said was that, you know, if we want to treat this like a...
- 33:15Oh no, it was Glyph.
- 33:16Glyph did a talk.
- 33:17Sorry.
- 33:18Jacob did a great talk on this same subject, but Glyph did a fantastic talk.
- 33:21The author of Twisted.
- 33:23And he got up there and he was saying, you know, look at this problem space that we have.
- 33:26We all agree that it's a problem, right?
- 33:29And everyone agrees.
- 33:30And he moves forward.
- 33:31And he's like, okay.
- 33:32So the problem is that we don't know what...
- 33:35We don't have anything to measure to see if we're improving on this problem.
- 33:38So the first thing we need to do is decide what does...
- 33:42You know, when this problem is solved, what does that look like, right?
- 33:44So to do that, you have to decide to measure something.
- 33:47So, you know, ideally it'd be like 20%.
- 33:50You know, so an example metric would be like 50% of Python downloads,
- 33:54of package downloads from the GShop or Python 3.
- 33:57Or like a majority of the downloads from Python.org for Python versions would be Python 3.
- 34:02Like, you know, let's pick something and try to optimize it, basically.
- 34:06And that was very much like what he was going for.
- 34:09He was like, let's not leave this room until we decide on a metric together.
- 34:13Or at least decide that we need a metric, right?
- 34:15And so it seemed as though everyone agreed that we needed a metric.
- 34:19We didn't even come close to deciding what it was.
- 34:21But it was a good discussion.
- 34:24And I feel like that there's a lot of merit to that type of thinking.
- 34:27You know, treating us like a software project instead of like a hobby project, basically.
- 34:32Right.
- 34:32Well, yeah, let's make this a data-driven problem that we can apply graphs and science and statistics to or whatever, right?
- 34:37Exactly.
- 34:38Awesome.
- 34:38Exactly.
- 34:39So I think that's going to happen this year.
- 34:41It got everyone thinking, so.
- 34:42Yeah, that's cool.
- 34:43Like, one thought comes to mind is like track the number of requests from PIP2 versus PIP3.
- 34:48Precisely.
- 34:49Just, you know, just not necessarily even the downloads.
- 34:51Just the number of like how much are people using this version versus that version, right?
- 34:56Those kinds of things.
- 34:56You should totally be able to track that.
- 34:58Yeah, and so there's some really great blog posts that have come out about this.
- 35:00Donald Stuff just did one today.
- 35:03His domain is caremad.io, I believe.
- 35:05And he just did his big blog post breaking down all the PIPI numbers.
- 35:11So I highly recommend checking that out because it shows you it's weird.
- 35:13Web people are adopting Python 3 faster than the rest of the Python community by about 4%, which is pretty interesting.
- 35:20That is really interesting.
- 35:22I think that is something I would have not predicted but would say, yeah, that seems like you're telling me something true.
- 35:28You know, just hearing out of the blue is because you have so much more control over the server, right?
- 35:32You manage a thing.
- 35:33On the other hand, if you're shipping it out to the world, you don't know where it's going to land, right?
- 35:38Exactly.
- 35:39Yeah, there's a scientific Python community.
- 35:41And I think that they're having smaller amounts of 3 adoption, but I have to learn more.
- 35:46Yeah, okay, interesting.
- 35:47Like the IPython guys and so on.
- 35:48Yeah, and Continuum.
- 35:49And like they support 3 with like Anaconda.
- 35:52I think that is like a new thing that people are still adjusting to because these scientists, you know, if you're a data scientist, you're probably not a programmer.
- 35:59And, you know, you're someone who can use these tools.
- 36:03And so you don't care if it's 2 or 3.
- 36:05You just want to get your job done, basically.
- 36:06So I think 3 has a lot of political buy-in, basically.
- 36:10Cool.
- 36:10So you said you work at Heroku, right?
- 36:12I do.
- 36:12I'm the Python overlord at Heroku.
- 36:14It's good to be an overlord.
- 36:16I enjoy it.
- 36:18So what do you do in there?
- 36:19What do you guys do with Python at Heroku?
- 36:21So I am basically, you know, Heroku supports a number of languages.
- 36:24We have like Ruby, Java, Node, PHP support, Python.
- 36:28And I am just in charge of everything related to Python.
- 36:31So I write a lot of documentation.
- 36:34I help customers and I just improve the product.
- 36:37And if you do like git push Heroku and like you have a Python app, then all the code that runs that is me.
- 36:43And then I go to speak to conferences and, you know, I'm on a podcast.
- 36:49This is technically work, I guess.
- 36:50It's a good gig.
- 36:53Yeah, this is work.
- 36:54Yeah.
- 36:54That's awesome.
- 36:55Yeah, it's really cool to be kind of out there as the community front for a cool company like Heroku.
- 37:02Yeah, I enjoy it.
- 37:03Do you guys use it a lot internally?
- 37:05Like what can you talk about what technology you have for yourselves?
- 37:08Yeah.
- 37:08So there's a couple different teams internally that use a lot of Python.
- 37:11There's specific spots in Heroku that are just kind of infrastructure that are written in Python.
- 37:17So if all of our Postgres servers get continuously backed up, the wall logs get continuously backed up to S3.
- 37:26And it's written with a tool called Wally, which we have open sourced.
- 37:29And if you go onto our GitHub, you'll see it's written in Python.
- 37:32And a couple different things.
- 37:35If you do a git push to us, I believe over SSH, I believe all of those are received by a twisted conch shell, which is pretty cool in Python.
- 37:44But there's a couple different teams internally that also use a lot of Python.
- 37:48There's the Heroku Connect team, which lets you interact with your Salesforce's data over Postgres.
- 37:53It gives you a Postgres database to read and write all your Salesforce data to.
- 37:57And that's like a Django app.
- 37:59And there's a couple other teams that, you know, a lot of tools that are built with Python.
- 38:04Cool.
- 38:04That sounds really interesting.
- 38:06Yeah.
- 38:06It's pretty great.
- 38:07So before we go, let me ask you a question that asks, you know, all my guests.
- 38:12In addition to requests, what is your favorite package on PyPy?
- 38:17I have to pick one?
- 38:18Well, give me a couple that you really like.
- 38:21Just kind of mostly when I just draw people's attention to stuff that's cool.
- 38:24Okay.
- 38:25So one of my favorites is called DocOpt.
- 38:27D-O-C-O-P-T.
- 38:28And what that is.
- 38:30So if you want to do a command line tool, you have to parse command line arguments.
- 38:35And to do that, it's not very fun.
- 38:37There's arg parse and opt parse that are built into the standard library.
- 38:41And they're both terrible.
- 38:43I wrote something that makes it a little easier.
- 38:45But this guy killed it.
- 38:46So what he did was, it turns out that the help string that's printed out when you do like command dash H, right, on the command line.
- 38:55You know how you see those like little brackets and stuff that like tells you all the different options?
- 39:00That is an ANSI standard, it turns out.
- 39:03And so what he does is you just you write the help script.
- 39:07Like you write the help page.
- 39:09And you know, and you like say all the different options.
- 39:11And you write, you know, the little arguments and which ones are optional and which ones are positional and all this stuff.
- 39:15And from that, he completely writes all the parsing code for you.
- 39:20So you just give it a string and you just say, give me my arguments.
- 39:23And it gives you a dictionary with all the stuff and the booleans and the true falses.
- 39:27And it's incredible.
- 39:28I love it.
- 39:28And that is really fantastic.
- 39:30Yeah.
- 39:31And it's been it's been ported to like every language.
- 39:34So but I think Python is the default one.
- 39:36So it's I'm a big fan of that project.
- 39:38Right.
- 39:39That's cool.
- 39:40I always feel like I'm reinventing the wheel when I go over there.
- 39:42It's like, OK, start from scratch.
- 39:43So that's great to bring that in.
- 39:45Yeah.
- 39:45Let's see.
- 39:47Another one that I am excited about but haven't used yet.
- 39:50It's called Click by Armin Roeneker.
- 39:51And I'm sure you'll talk to him about that when you do your podcast with him.
- 39:54But a couple of years ago, I wrote a library for myself called Clint.
- 39:59And Clint was a command line application tools.
- 40:03It's a set of utilities, basically.
- 40:05I had a bunch of cool stuff in there like, you know, prompting for yes and no, parsing
- 40:10arguments, writing files to the home directory on every type of computer, you know.
- 40:16And I had my favorite module that I had in there was called eng.join.
- 40:21So you would give it, you know, a list of strings.
- 40:24And then it would it would join them properly with like an Oxford comma and conjunctions, you
- 40:30know.
- 40:30Oh, nice.
- 40:32Yeah.
- 40:32It's like really cool code.
- 40:33But it kind of I need to separate all that stuff out because it's kind of a dead project.
- 40:37I haven't used it in years.
- 40:38And click is Armin's approach to the same problem.
- 40:43It doesn't do all the same stuff.
- 40:45But it's like, you know, Armin does amazing code.
- 40:47And so this is a project that just is like, if you're going to write command line applications,
- 40:52you need to use click.
- 40:53So I'm really excited about that.
- 40:54Cool.
- 40:55Oh, excellent.
- 40:56Those are really nice.
- 40:58If I wanted to get started with Heroku as a Python, let's say I'm writing a Django app or Flask or something.
- 41:04What do I do?
- 41:05Well, you go to Heroku.com and you sign up for an account and it should tell you what to do.
- 41:09Awesome.
- 41:12Okay.
- 41:12So everyone check that out.
- 41:14Yeah.
- 41:15And if you have any questions about Heroku and Python, feel free to reach out to me or tweet at me or whatever.
- 41:19Yeah.
- 41:20Very cool.
- 41:20Any final shout outs you want to give?
- 41:22Off the top of my head?
- 41:24What do you think?
- 41:25I'm going to shout out to you for making this awesome podcast.
- 41:28Oh, thank you very much.
- 41:29I appreciate it.
- 41:30You're welcome.
- 41:31The world needs more Python podcasts.
- 41:33I agree.
- 41:33You're doing good work.
- 41:34Yeah.
- 41:35My original goal was not to start a Python podcast, but just to talk to some of them.
- 41:39And I found that they all had their last show like a year ago.
- 41:43I'm like, wait a minute.
- 41:44That can't be right.
- 41:45Nice.
- 41:45Looked and looked and looked and looked.
- 41:46Yeah.
- 41:47It's sadly right.
- 41:48Mine included.
- 41:49I have a one episode podcast, but it was great.
- 41:53It had 6,000 listens.
- 41:54That's awesome.
- 41:55Where do people find it?
- 41:57It's called Import This.
- 41:59Import This.
- 42:00It's called Skainer and I.
- 42:01And we have two other episodes recorded.
- 42:04It's just a matter of editing time.
- 42:05I would like to get a sponsor.
- 42:06So if we got a sponsor, it would be easier to edit.
- 42:09It would boost you back into it.
- 42:12Yeah.
- 42:12It's just like it took me eight hours to edit the first episode because I was doing like
- 42:16Radiolab quality.
- 42:17So I either need to just settle for lower quality or ideally I'd be able to pay a company to edit
- 42:25it for me.
- 42:26But I don't know.
- 42:27We'll see.
- 42:27Exactly.
- 42:29That would be nice.
- 42:29I think editing is actually the most work.
- 42:31It is.
- 42:32Yeah.
- 42:33It's ridiculous.
- 42:34So we'll get back to it eventually.
- 42:36Definitely.
- 42:38Well, you should.
- 42:39All right.
- 42:39Kenneth, thank you so much for being on the show.
- 42:41It's been really interesting.
- 42:42And I especially appreciate like the insight into the language summit and stuff like that.
- 42:46Absolutely.
- 42:47Thanks for having me.
- 42:48Yeah.
- 42:48You bet.
- 42:49And I will talk to you later.
- 42:50Have a good one.
- 42:52This has been another episode of talk Python to me.
- 42:55Today's guest was Kenneth Wright.
- 42:57Thanks, Kenneth.
- 42:58Remember, you can find the links from the show at talkpythontimmy.com slash episodes
- 43:04slash show slash six.
- 43:06And if you're feeling generous, please check out our Patreon campaign at patreon.com slash
- 43:11mkennedy or work with your company to encourage them to sponsor an episode.
- 43:15Be sure to subscribe to the show.
- 43:17Visit the website and choose subscribe in iTunes or grab the episode RSS feed and drop it into
- 43:23your favorite podcatcher.
- 43:24You can find both these in the footer of every page.
- 43:26This is your host, Michael Kennedy.
- 43:28Thanks for listening.
- 43:29Stay tuned.
- 43:50.