Latest / Talk Python To Me / #152: Understanding and using Python's AST
Transcript
- 0:00Have you heard of ASTs or abstract syntax trees?
- 0:02If you have, it was probably in the context of a compiler or some kind of parser.
- 0:06They're a really powerful data structure, but we often only use them
- 0:10really indirectly by using those types of tools.
- 0:12They're just such a, well, you know, abstract idea to most of us.
- 0:16This week, you'll meet Emily Morehouse. She's here to make this abstract concept
- 0:20much more concrete and discuss the places where the AST can help us write and maintain
- 0:24better code. This is Talk Python To Me, episode 152, recorded February 5th, 2018.
- 0:31Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries,
- 0:50the ecosystem, and the personalities. This is your host, Michael Kennedy.
- 0:54Follow me on Twitter, where I'm @mkennedy. Keep up with the show and listen to past episodes
- 0:58at talkpython.fm and follow the show on Twitter via at Talk Python.
- 1:02This episode is brought to you by ParkMyCloud and Rollbar. Please check out what they're
- 1:07offering during their segments. It really helps support the show.
- 1:10Emily, welcome to Talk Python.
- 1:12Hello, how are you doing?
- 1:13I'm doing really well. It was so nice to meet you in Vancouver, and I really enjoyed the talk
- 1:18that you gave about the abstract syntax tree. You made this abstract idea kind of concrete.
- 1:23It was nice.
- 1:23Thank you. Yeah, I've gotten some really, really positive feedback from it. So I was very happy
- 1:28to be a part of it.
- 1:28Yeah, it was really cool. And we're going to talk all about the AST and what it means in
- 1:33Python, where it comes in, how you can actually leverage it to do all sorts of cool stuff.
- 1:37But before we get to all those things, let's start with your story. How did you get into
- 1:39programming in Python?
- 1:40So I kind of stumbled into it. I was a student at Florida State University. I was actually studying
- 1:46theater and biochemistry. And I did an internship.
- 1:50That's quite the mix.
- 1:51Yeah. Yeah. But I did an internship at a lab and realized that I could not see myself doing
- 1:57biochemistry for the rest of my life. I also knew that I wasn't going to make a whole lot
- 2:01of money doing theater. So I was really interested in forensics. So I figured if I couldn't do the
- 2:07biochem side, that I would go to the criminology side.
- 2:10So I started in criminology. And it turned out that FSU had just launched a computer criminology
- 2:16program. And so this was, I think, my junior year, like summer of my junior year of college.
- 2:22And they were like, hey, you have really great math scores. Like, why don't you go take a programming
- 2:26class? And I did. And I absolutely fell in love with it. It was like an intro to programming C++ class.
- 2:32And I built an Enigma machine simulator.
- 2:35Oh, wow. That's cool.
- 2:36The rest is history. Yeah.
- 2:37Yeah. That's really awesome. So this like sort of data driven criminology, is this like
- 2:43a little bit like CSI, like forensic type stuff? Or what kind of things would you have done there?
- 2:49Yeah. It was a lot of focus on security, a lot of focus on digital forensics. So taking like a dead
- 2:55hard drive and trying to reformulate a lot of the data that you can get off of it,
- 3:00that kind of stuff. That sounds pretty interesting. And I guess, you know, you were thrown right into
- 3:05like the deep end with C++. So if you like that, then, you know, this whole thing must be for you,
- 3:11right? Exactly. Yeah. And I think that looking at my history and how I got into programming and
- 3:16coming from a CS background, that was very, very focused on theory and compilers and all that.
- 3:21That's definitely where a lot of this stems from. Yeah, yeah, I'm sure. So how'd you go from
- 3:27C++ to Python? That's a bit of a complicated answer. So part of it was that I started building
- 3:34a lot of like side projects with friends. And so we would go through and like figure out how to build
- 3:39a web scraper and stuff like that. And then we started building APIs. And then my university
- 3:44actually offered Python courses. So I was able to take Python and like an advanced Python course.
- 3:50And then I wound up using it for a lot of the research programs that I was working on,
- 3:54because it's really great with data processing and building graphs and all that.
- 3:58Right. It's a lot quicker than trying to do that in C++.
- 4:00Yeah.
- 4:01I don't know what. OpenGL, who knows? Something crazy.
- 4:04Yeah. I had to do a little bit of R at one point as well. And I much prefer Python over R.
- 4:09Yeah, yeah, that's cool. All right. Well, that's a really cool origin story,
- 4:12how you got started. How about now? Are you still working in criminology?
- 4:17Not quite. I almost did. But I kind of had another interesting turn and wound up starting a company.
- 4:23So I actually am the co-founder and director of engineering of a company called Cuddlesoft.
- 4:28And so we are a digital product development company. So we work with a lot of different types of clients,
- 4:35anywhere from nonprofits to other tech companies. And we build anything from web and mobile applications
- 4:42to cloud migrations and embedded systems. And yeah.
- 4:46Yeah. That sounds like a lot of stuff, but it sounds like a really cool company. I looked around your website.
- 4:50It looks really, really slick and friendly. And I like it a lot. So it sounds like you must have a ton of technologies at play, right?
- 4:58Like as soon as you say mobile, there's probably some Java and some Swift or at least a lot of JavaScript somewhere in there.
- 5:03But yeah, what's it like?
- 5:05It's really fun. I think I consider myself lucky to be able to really hone my sort of polyglot skills.
- 5:12I really enjoy knowing a lot of different languages and being able to see how building a product in one language is different than using another.
- 5:21Even like different type systems between Swift and Java. And like, yeah, those are all debates that I love getting into.
- 5:28Yeah, those are cool. And I think knowing those languages gives you a richer perspective on any one of them, right?
- 5:35Being able to think about it and look at these things from different perspectives.
- 5:38I absolutely agree.
- 5:39I think it's cool. Yeah, nice.
- 5:41So you guys also run a podcast, right? I just learned. Tell me a little bit about your podcast.
- 5:47Yeah. So our podcast is called Startup Capital. It's a little bit of a play on words.
- 5:51So our original office started in Tallahassee, Florida.
- 5:56And there was a huge movement of entrepreneurs and like there's a business incubator and just a huge focus on entrepreneurship.
- 6:05And so we started a podcast to kind of highlight each of those stories and how everybody's businesses were going, how they relate to the community, how everything is kind of giving back to Tallahassee and really taking a look at what Tallahassee's ecosystem for entrepreneurs looks like.
- 6:20That's cool. That sounds really interesting.
- 6:22There's definitely seems to be a lot of entrepreneurship in Florida for some reason.
- 6:26I don't know why that is, but it definitely seems like it.
- 6:29Yeah. I mean, we got started there.
- 6:30Yeah. Well, there's exactly one cool example.
- 6:35So let's talk a little bit about the conference and then we'll get into your talk.
- 6:39So I learned about your presentation and stuff just by going to PyCascades, which was a new conference in Vancouver this year.
- 6:49I thought it went really well, your talk, but also the whole conference.
- 6:52What do you think of the experience?
- 6:53I absolutely agree. So this was actually my first regional conference that I had attended.
- 6:58I attended PyCon previously, but for me, regional conferences are a lot more digestible, a lot less intimidating, a lot less exhausting.
- 7:06So for me, like the two day conference experience is like the perfect length.
- 7:11Yeah. I feel like when you go to PyCon, it's kind of like the paradox of choice, right?
- 7:14It's like, oh, there's 10 tracks and there's open spaces and I can even skip all that and hang out with these people and cruise around the expo hall.
- 7:22And there's just like, you know, so much to do, right?
- 7:24It was pretty clear, like you either do this, the main track and you're in there with everybody or not.
- 7:29And that's definitely a different experience.
- 7:31Yeah. But I think the whole thing was really great.
- 7:34I know that I felt very welcomed and very supported as a first time conference speaker.
- 7:39And I was very, very happy to be invited into the PyCascades community, even as somebody who ventured all the way from Colorado.
- 7:50Yeah, that's cool. It was really nice.
- 7:52Yeah, there was there were a lot of Americans for a Canadian conference, but it was still nice to meet everybody from from all over the place.
- 8:00I got to say, your presentation was really well done.
- 8:02And I think it was from a sort of slides visual perspective, one of the most interesting ones there, like it had a animated gifs, little puppies, and it had all sorts of stuff to keep it interesting.
- 8:15You know, people so often just go present like a wall of text and you're just like, I'm sure what you're saying is super interesting, but this isn't convincing me of it, right?
- 8:22I had to be very conscious about how I presented a lot of this information because it can be very dense and a little bit confusing.
- 8:30So I knew that I had to make it interesting for one, cue puppy gifs.
- 8:34And I also knew that I had to relay a lot of the information in a very visual fashion so that people could see the trees and understand what they looked like instead of trying to put words together to describe it.
- 8:46Yeah, absolutely. There's definitely a lot of visual stuff in there.
- 8:49So let's start by maybe asking the question, like, should you care about Python internals?
- 8:56I mean, we're going to dive pretty deep into the internal of how Python works and stuff.
- 9:00And on one hand, you could kind of blissfully ignore that, you know, pip install requests in beautiful soup, screen scrape, you're done.
- 9:08So maybe why do you think people should look a little deeper?
- 9:11By understanding how your code works under the hood, it can give you insights into the approaches that you're using to write your code.
- 9:20I also think that it's really interesting to learn about how Python works as a language and then how you can leverage that to build different tools, whether you're using the actual Python AST that gets generated or just knowledge of ASTs to build other really neat tools.
- 9:37Just to know that you can leverage these ASTs to do more or even change how things execute is, it's pretty cool to know.
- 9:46And it's not at all obvious that that's possible, right?
- 9:48Absolutely.
- 9:48Yeah, yeah.
- 9:49So what we're going to focus on mostly is around taking Python source code, getting it to abstract syntax trees and into bytecode.
- 9:59Like once the bytecode runs and that sort of is a whole nother area.
- 10:03So I just want to give a shout out for people who are interested in this to Philip Wo's 10-hour CPython code walk.
- 10:10And I did an episode on that with him, like looking inside the CPython implementation at that sort of disassembly part.
- 10:16A whole bunch way back on episode 22.
- 10:19So that's kind of a good compliment to this.
- 10:21But let's maybe start by talking about how do we go from source code to machine instructions executing, right?
- 10:30Like actual stuff happening.
- 10:31And you posed a really interesting question of asking whether Python is interpreted or compiled.
- 10:36What's the answer?
- 10:37The answer is both.
- 10:39Usually there's somebody in the audience who actually gets that one right, which I really appreciate.
- 10:43But yes, Python is actually both.
- 10:45It seems, you know, like you hear that Python is interpreted, so there must be no compile step.
- 10:50But the thing that actually gets interpreted is a bunch of compiled bytecode.
- 10:55It doesn't get down to machine instructions.
- 10:57It just stays these sort of higher level bytecode things, right?
- 11:00So maybe talk a little bit about that process.
- 11:02Exactly.
- 11:03So the compiler generates your bytecode, and then the interpreter actually executes your bytecode.
- 11:09So essentially what you do is you take your source code that gets parsed into what's called a parse tree.
- 11:14And then for various reasons, your parse tree gets to be a little bit too detailed and is a little bit harder to work with.
- 11:22So you actually transform that into an abstract syntax tree.
- 11:25Is the parse tree like basically almost exactly what you typed, whereas the abstract syntax tree is like the meaning, like the essence of what you typed?
- 11:33Yes, exactly.
- 11:34So one of my favorite examples to use is a math expression.
- 11:38And so all of us are taught from a very young age the order of operations, right?
- 11:44So you know that if you have one plus two in parentheses times three, you know, based on the order of operations, that you execute the parentheses first and then you multiply.
- 11:56And so that's one of my favorite examples to use from parse tree to AST, because when you have your AST, you can actually automatically know the order in which you have to perform your operations just based on how the tree itself is laid out.
- 12:12Instead of having to know, oh, well, I have parentheses, so I have to worry about that too.
- 12:17Right, right.
- 12:18And we don't have your great pictures to help here because this is audio.
- 12:22But, you know, imagine a tree where the top operation is multiply and then like each branch, one is like the three and the other is one plus two.
- 12:29You just you just go down it and evaluate it.
- 12:31Right.
- 12:31It's pretty, pretty straightforward once it's in that mode.
- 12:33Yeah, that's cool.
- 12:34OK, so we were we're talking.
- 12:36So we have source code.
- 12:37It gets parsed into a parse tree and then into an abstract syntax tree.
- 12:42And then what?
- 12:43And then you take your abstract syntax tree that gets transformed into what's called a control flow graph.
- 12:49So if you think about it, an AST is still represented in a very hierarchical fashion, whereas your CFG, you can actually have cycles or loops that can mimic the actual control flow of your program in a better way.
- 13:02And then from there, you can actually emit your byte code that winds up being executed.
- 13:07Right.
- 13:08And can we find this byte code?
- 13:09Like, does it land on disk somewhere when we run our code?
- 13:11Yeah, absolutely.
- 13:12So most of the time, all of your byte code is actually stored in PyC files.
- 13:17It used to also get stored in PyO files back Python 2, if you're still using that.
- 13:23Yeah.
- 13:24And it's in that dunder PyCache that you sometimes see hanging around, right?
- 13:28Yeah.
- 13:28So Python 3, they were very kind to organize all those PyC files into your PyCache directory to kind of get them out of the way.
- 13:35Yeah.
- 13:36The one thing is, here's junk, you can throw it away.
- 13:38Yeah.
- 13:39So let's start talking about working with this, maybe just by focusing on the tools.
- 13:45So there's a couple of modules built into Python directly that lets you work with this byte code and these trees and stuff, right?
- 13:52Yeah.
- 13:53So there are two modules that are built in that I use a lot.
- 13:56One of them is the AST module.
- 13:58So this is made to assist you in actually interacting with the AST that Python generates.
- 14:05And it also has a bunch of helpers that you can use to support translations from your source code into an AST, AST into code objects, and then actually executing the code from those code objects.
- 14:19Yeah, that sounds really interesting.
- 14:20So let's see, you could take the AST module and you could like parse just source text, right?
- 14:27And I guess you could either get that from a file by reading the text of the file, or you literally could just give it text, right?
- 14:32That's pretty interesting.
- 14:33And if you want to look at it, though, you can't, you know, it's just like an object in memory.
- 14:37It's like underscore AST dot, I don't know, node or expression or something at some address, right?
- 14:43It's completely hard to make any sense of.
- 14:44But there's a nice dump thing, which will dump it sort of back to, what is that, like a text version of a tree or something?
- 14:52I'm not entirely sure.
- 14:53It's this huge glob of tree data.
- 14:56So the easiest way to actually interact with it is to do like a traversal and actually walk over your AST, which is actually, I have a few like third party libraries that make that a little bit easier that abstract away actually interacting with the tree and it handles, you know, what is your next step?
- 15:15Right. Okay.
- 15:16Yeah. And then there's actually some really neat visualizations that have been built that you can actually just give it your source code that you want to visualize.
- 15:24And then it'll print out of an actual tree representation.
- 15:28It has like an SVG.
- 15:30So you can visualize that you can even take these nodes, these abstract syntax trees and say compile them and then look at their underlying bytecode, right?
- 15:40Just all in memory.
- 15:41Yeah, exactly.
- 15:42So what I kind of did was I approached it as trying to kind of step through as much of the compilation process as I could just by looking at the AST.
- 15:52So actually going from your source code, kind of skipping the parse tree, going to the AST and then being able to see your bytecode and interact with it.
- 16:01And so everybody always says that everything in Python is an object.
- 16:05And that actually is true down to the smallest, most integral parts of the actual implementation of the language.
- 16:13So your source code gets compiled into what's called code objects.
- 16:18And then those code objects store things like disassembled bytecode or sorry, the assembled bytecode.
- 16:25Just the straight numbers, right?
- 16:27Like three, 102, seven.
- 16:30Yeah.
- 16:30And it's actually stored as bytes.
- 16:33So they're not even like human readable.
- 16:35So you can actually, you have to go in there and poke at it a little bit and to get everything translated into integers so that you can actually read it as a human.
- 16:44Right.
- 16:44So once you compile it here or if you use the disassembly module, you can just go to the code objects and they have like a .co underscore code, which is, that's the bytes you're talking about.
- 16:54And then you can do a couple of things.
- 16:57You could actually just re-execute it in case you're messing with it here or you could disassemble it.
- 17:01So I kind of sidetracked you when you're talking about the tool.
- 17:04So there's the AST module, which does all the stuff that we're talking about, right?
- 17:08It'll take source code and you can actually turn it into an AST, but you are also talking about the disassembly module?
- 17:14Yes.
- 17:15So the disassembly module allows you to take your code objects and actually shows you sort of the machine instructions as they get executed.
- 17:25And it also shows you like the registers that they use and a bunch of information, but it makes it a lot easier to actually just look at the disassembly bytecode because it goes through a lot of the lookup processes for you.
- 17:38So I'm not going to remember what these are off the top of my head, but if you see like instruction 101, there's actually a giant switch statement in the CPython interpreter that goes through and says, okay, instruction 101.
- 17:52I know that that is supposed to be, I don't know, a load.
- 17:54Load function or like add a variable to the call stack or something like that.
- 18:00Yeah.
- 18:01There's literally like this huge switch statement that is like 3000 lines in C eval.c and CPython.
- 18:07That's like just every one of those codes.
- 18:10Okay.
- 18:10It's code 101.
- 18:11What does that mean?
- 18:12What do I do with that?
- 18:13Right.
- 18:13And so the disassembly module basically take this bytecode, whether you got it just from running and directly some bit of code or, or from messing with the AST and it'll show you that and kind of the raw steps, almost the assembly language of Python.
- 18:28Right.
- 18:29As close as you're going to get anyway.
- 18:30Yeah.
- 18:31Right.
- 18:34This portion of talk Python to me is brought to you by park my cloud.
- 18:37The last time you parked your car, did you leave it running?
- 18:40No.
- 18:41Well, then why are you leaving your cloud resources running?
- 18:44Every year, $13 billion are wasted on cloud instances that no one is using.
- 18:50Don't let any of those be yours.
- 18:52Park my cloud automatically identifies and eliminates wasted cloud spend, saving you 65% on AWS, Azure,
- 19:00and Google's cloud.
- 19:01You're up and running quickly with a 10 minute setup and no scripting required.
- 19:05Plus govern users and easily integrate into your DevOps process.
- 19:09See why park my cloud was chosen by McDonald's, Unilever, Fox, and more.
- 19:14Start a free trial today at parkmycloud.com slash talk Python.
- 19:19So those are the two built-in ones.
- 19:21And then there's a couple of others that let you dig around.
- 19:24There's AST or AST or how do you say it?
- 19:28How do you think?
- 19:29I've pronounced it as Aster.
- 19:30Aster.
- 19:31That sounds more fun.
- 19:31Yeah.
- 19:32Tell us about that.
- 19:32And it's a derivative of CodeGen, which comes from Armin Roeneker of Flask fame as well.
- 19:37Indeed.
- 19:37Yeah.
- 19:38So he started out by writing some CodeGen and there were a few little holes that it had.
- 19:44So other people in the community kind of picked it up and patched it together.
- 19:48And so both Aster and there's another package called Meta.
- 19:52They're kind of focused on taking bytecode or an AST and generating the code from it, like your original source code from it.
- 20:01And so it's kind of focused on this like reverse engineering of bytecode and ASTs.
- 20:05And then Aster also provides some really cool like pretty printing and ways to manipulate the AST.
- 20:10So if you want to like inject code in certain parts of the AST, it provides helpers to do that.
- 20:16Right.
- 20:16Every time you see this type of pattern, like wrap it in whatever, right?
- 20:20Something to that effect, right?
- 20:22Mm-hmm.
- 20:22Yeah.
- 20:23Yeah.
- 20:23Cool.
- 20:23With the straight AST module, can you modify the ASTs as well?
- 20:28I don't know if there are any helpers that kind of make that process easier, but you can go in and actually like edit the data structure.
- 20:36So there is an actual like underscore AST data structure that you can interact with.
- 20:42If you want to just do it at the lowest level, I guess.
- 20:44Yeah.
- 20:45Yeah.
- 20:45So there's a couple of interesting things that the Aster and Kojen did.
- 20:51You talked about the pretty printing.
- 20:52They let you kind of traverse the tree in a less heavyweight way, I guess, is one thing it does.
- 20:59But it also does this concept of round tripping.
- 21:01Tell us about this idea of round tripping.
- 21:04I am really interested in round tripping for a few different reasons.
- 21:07But basically what you can do is you can take your source code, translate it into an AST, and then translate it back into Python
- 21:14and see how much your code has changed.
- 21:16So the idea of round tripping can actually be used in sort of refactoring or going through and linting code.
- 21:24So there are certain changes that you can make to your code that doesn't change the underlying semantic meaning that you can see through the AST.
- 21:34So it's a way to kind of guarantee that you've made changes to the syntax of your code, but you haven't actually changed how your code is working or what it's doing.
- 21:43Right.
- 21:43It's like the linter says, you really should format this way or you should tweak it around that way.
- 21:48Right.
- 21:49But it really should have exactly the same meaning.
- 21:51If the AST changes, well, it doesn't have the same meaning.
- 21:54Right.
- 21:55So this is kind of a byte level check almost.
- 21:59Yeah, I could see a unit test that kind of like snapshots the AST, saves it as like a pretty printed text, and then, you know, just compares again.
- 22:09Does that change?
- 22:10Did that change?
- 22:11All right.
- 22:11And if it ever changed, it kind of failed.
- 22:13That's pretty interesting.
- 22:14Another one that I ran across recently that kind of falls into this general realm of like digging inside the bytecode, it's not technically to do with ASTs, I don't think.
- 22:24It's more about the disassemblies, this thing called Python Hunter.
- 22:27You've seen that, right?
- 22:28Yeah, I recently looked into it.
- 22:30They do some really cool things with code tracing, and it'll actually kind of show you at a very low level each step that your code is taking under the hood.
- 22:39Yeah, so it's kind of like logging the disassembly as your code executes.
- 22:44It's pretty funky, that thing.
- 22:46But yeah, it's definitely just another library.
- 22:48There's probably, you know, 10 others that we're forgetting or we don't even know exist, right?
- 22:52Out of the 125,000 PyPI packages, there's got to be some more in there.
- 22:56Nice.
- 22:57Okay, so let's see.
- 22:59One thing that you talked about in your talk that I thought was interesting is that we can use the disassembly module to check out our code,
- 23:08like take the bytecode and sort of look at it in these lower level operations.
- 23:12But the bytecode and the source code, they don't always line up, right?
- 23:15Sometimes the bytecode is more verbose.
- 23:17Sometimes it's less verbose than our source code.
- 23:19And maybe tell people about that mismatch there.
- 23:21One of the things that you always kind of assume is that there's some sort of optimization that happens under the hood.
- 23:29And so you can actually see how a lot of those optimizations happen by looking at your bytecode.
- 23:35The two I remember are the peephole optimization and the constant folding.
- 23:39Yeah.
- 23:40So I guess I can describe them first.
- 23:42The two most common ways that Python is optimized under the hood is the peephole optimizer.
- 23:48So the way I like to think about that is looking around without moving your head.
- 23:53So kind of using your peripheral vision to see your direct surroundings and then being able to make intelligent choices based on those surroundings.
- 24:01So as humans, we have learned that if you have x equals 1 and then y equals x plus 2, we automatically know since x equals 1 that we can kind of substitute those values in.
- 24:15And that's one of the things that the peephole optimizer does.
- 24:19And the other optimization is called constant folding.
- 24:23And so basically you can evaluate constant expressions at compile time instead of at runtime.
- 24:30Right.
- 24:30So for example, if you had like what I have all the time in my web apps is there's usually some part that says, how long do you want to cache this for?
- 24:39And it's sometimes in milliseconds and it's sometimes in seconds.
- 24:42And I don't want to write, you know, 236,414 seconds.
- 24:47All right.
- 24:48Like 60 times, 60 times, 24 times, 31, a month's worth of seconds.
- 24:53Do the math for me.
- 24:54And what you're saying is that Python will actually do the constant folding and go, well, that's the, you know, whatever actual number that is.
- 25:00Just before it ever runs.
- 25:02Right.
- 25:02Yeah, exactly.
- 25:03And it tries to look out for you a little bit.
- 25:06So one of my other favorite examples is if you have like a double negative in your logic.
- 25:12So if you have something like not A, not in B, the compiler actually goes, oh, no, no, no, no.
- 25:19I know what you're trying to say here.
- 25:20This is simply just A and B.
- 25:22Like, let me simplify that for you.
- 25:25Right, right.
- 25:25I don't need to do three tests for you.
- 25:27I'll just do the one or two.
- 25:29However, however you count not in.
- 25:31Yeah, that's totally a good idea.
- 25:34And that's one of the people optimizations as well.
- 25:37It's like there's a whole class there.
- 25:39So things that I don't think happen are things like what C++ might do where you might like inline non-virtual function calls and stuff like that.
- 25:48So I don't know.
- 25:50There's I think it's pretty interesting that one of the big focuses recently on Python is around its performance.
- 25:56I think that was the 3.6 work.
- 25:58I can't remember.
- 25:59But like Victor Stinner and some of those guys are like, we're going to make a bunch of improvements on like function call speed and stuff.
- 26:06And so they're getting better at the optimizations for sure.
- 26:09But yeah, it's not too advanced, right?
- 26:11Correct.
- 26:12Yeah.
- 26:12I think one of the things that happened with Python 3 is that when Python 3 was first released, it was actually a little bit slower than Python 2.
- 26:20And so I think they realized that they really needed to put a lot of focus into at least making it as fast, if not faster, than Python 2.
- 26:28Yeah, we've had this big challenge for quite a while, which I feel like we're on the verge of sort of putting that behind us.
- 26:36But the sort of Python 3, Python 2 wars, it is hard to say you should choose Python 3 when it actually slows down everything you do, right?
- 26:46Exactly.
- 26:46Yeah, that definitely is not what you want on your side of the argument.
- 26:49So it's good that they're making it faster and using less memory.
- 26:52Like there was that whole presentation at PyCon 2017 from Instagram.
- 26:57I don't know.
- 26:57Did you see that one?
- 26:58I might have.
- 26:59Yeah.
- 26:59So they've talked about upgrading from Python 2 to Python 3 from Django, some old version to like modern Django.
- 27:05And they basically save like 12% on their memory usage and something similar around performance just by upgrading.
- 27:11So, you know, it's finally getting to the point where it's better to upgrade, not worse.
- 27:17So that's pretty awesome.
- 27:18All right.
- 27:19So these abstract syntax trees, it's interesting to know that they work.
- 27:24It's kind of cool.
- 27:25It's kind of cool.
- 27:25It gives you some insight into your code like we talked about.
- 27:28But, you know, let's talk about some of the applications because, you know, it's sort of an abstract idea until you can do something constructive with it.
- 27:37So you had a bunch of different applications that you talked about.
- 27:41I think it's kind of a lot of things that you're going to do something like 100% of the code coverage for your tests.
- 27:45So you're going to do something like 100% of the compiler does.
- 27:49There's also a few like very random cases where if you're trying to get like 100% code coverage for your tests.
- 27:57There's actually certain cases that if you have an if else statement, for example, that your else, the actual line for the else doesn't actually get executed.
- 28:07So there are certain like weird things where you're like, I don't know, I can't get my else to execute, but I know that it executes.
- 28:14Yeah.
- 28:15Yeah.
- 28:15So there are certain ways that you can use this knowledge to sort of debug different errors that you're encountering.
- 28:21Right.
- 28:21Or if you're super obsessed about getting 100% code coverage.
- 28:25Yeah.
- 28:25You just want to force that to happen.
- 28:27Yeah.
- 28:28Another thing is if you wanted to create your own sort of domain specific language derived from Python, right, if you want to change the grammar a little bit.
- 28:37So that's kind of one of the fun things about Python is that anybody can sort of propose a PEP and propose a change to the language.
- 28:44So if you did want to actually get in there and change Python's grammar, you can do that fairly easily.
- 28:50There's a lot of blog posts out there about how to actually get in there and do it.
- 28:54Yeah.
- 28:54It's probably a pretty tough sell to get them to accept like a new concept, right?
- 29:01Usually.
- 29:01Yeah.
- 29:01Yeah.
- 29:02I mean, that's one of the things where like once it's in there, you have to live with it no matter what.
- 29:07Right.
- 29:08If it's in the language, unless you're doing a major break and change like Python 2 to 3, like generally,
- 29:14you know, it's kind of like the gift of a puppy, right?
- 29:16You have it once you've received it.
- 29:19Nice.
- 29:19And then we talked about round tripping already.
- 29:21That's another interesting application to sort of verify that changes based on linting or automatic linting actually don't make any significant, you know, any meaningful change to the underlying bytecode.
- 29:34That's pretty interesting.
- 29:36Maybe one of the ones where people see the most is around this idea of code generation.
- 29:40Yeah.
- 29:40So code generators are really cool.
- 29:42And it's actually one of the things that I learned in this process is that there's actually some decent chunks of Python itself and Python's compiler that are actually generated.
- 29:52Oh, that's pretty cool.
- 29:53Yeah.
- 29:53But you can use code generators for a lot of really neat things.
- 29:57So one of them is called Pythoscope.
- 29:59Now, what's that?
- 30:00It will actually essentially generate unit tests for you.
- 30:05So if you have a project that you haven't actually written any tests for, you can use Pythoscope to kind of kickstart that process.
- 30:11That's cool.
- 30:12So the logo they have is like this doctor checking out like a sick snake.
- 30:18It's a pretty good logo, actually.
- 30:21It's funny.
- 30:23So look at this.
- 30:24It says you take the old code and sort of run this thing across it.
- 30:29It will write what it thinks are the unit tests for you in comments for all the various things.
- 30:35And it just fails all the tests.
- 30:37But you can sort of uncomment them and make them real, which is pretty cool.
- 30:41And it apparently uses the abstract syntax tree to go understand the various pieces, right?
- 30:47Yeah.
- 30:47So it uses the AST to kind of figure out what tests that it can actually generate and what needs to be tested and all that.
- 30:54Oh, yeah.
- 30:54That's cool.
- 30:54That's a really nice way to do it.
- 30:56So another thing that's pretty interesting is this thing called Transcript.
- 31:00And I've never heard of Transcript.
- 31:02It's apparently a Python in the browser, sort of a JavaScript to, sorry, a Python to JavaScript compiler type thing like Babel.
- 31:13Have you played with this?
- 31:14Have you seen it?
- 31:15I haven't played with it before, but it's really interesting.
- 31:18So I think that that's one of the things that a lot of people are trying to do is they're trying to make Python a lot more portable.
- 31:23And one of the things I have also learned, I'm just a fountain of knowledge over here.
- 31:28Python was almost the JavaScript of browser languages.
- 31:33Oh, really?
- 31:34Yes.
- 31:35That would have been nice.
- 31:37Yeah.
- 31:38Way back in the day, I think there was like an old Netscape browser that was actually built using Python as it's like in browser language.
- 31:46Wow, that's cool.
- 31:47Yeah.
- 31:47So, you know, Netscape back in the day, that's when they came up with JavaScript just for Netscape, right?
- 31:54So, too bad.
- 31:56But yeah, there are a couple options.
- 31:58There's Sculpt and there's a couple of others.
- 32:00But I don't know how the others work.
- 32:02Maybe similarly.
- 32:02But at least this transcript one, which I didn't know was an option until now, that one uses AST to sort of generate the JavaScript equivalent from Python, which seems like a pretty good way to do it.
- 32:15Yeah, I think that transpiling languages is fairly common.
- 32:20So, like you mentioned, there's definitely a lot of transcription in the JavaScript world just going from newer, you know, ES7, ES6 syntax to original ES5.
- 32:31That's a pretty interesting thing to just say, we're going to solve the version problem by recompiling it down to a different version of source code for you.
- 32:40Yeah.
- 32:40I'm not sure it's a good way, but it's an interesting way.
- 32:44As somebody who has to work with a lot of JavaScript, I definitely prefer the newer syntax.
- 32:49And I definitely appreciate being to use, you know, arrow functions and all that.
- 32:53Yeah, the new JavaScript is a lot better, although it feels much more engineered.
- 32:58Like you almost need a CS degree to properly work with modern JavaScript, where it used to be just this few jQuery selectors and go with it.
- 33:06Real simple type thing, right?
- 33:08Yeah, but I definitely think that that's also sort of reflected in the amount of weight that we're making JavaScript carry in, you know, modern web applications.
- 33:18Yeah, that's true.
- 33:19They are doing a lot, aren't they?
- 33:21Yeah.
- 33:21So another thing that you talked about was reformatting code.
- 33:24How does that work?
- 33:26So I think there are these ideas using things like AutoPep 8, where you can kind of translate your code and impose certain restrictions.
- 33:35And so one of my favorite ones is, I think it's just yet another Python formatter.
- 33:43Yep, of course.
- 33:46Yeah.
- 33:47And so that one's really neat.
- 33:48It takes a very intelligent approach to actually looking at your code and seeing at a more underlying level what your AST is actually doing and being able to make certain choices based on this advanced knowledge that it has of your code and how it can actually transform it and almost refactor it in a way.
- 34:09It's pretty cool.
- 34:10They have a little online demo that you can play with.
- 34:12And I think this comes from Google, right?
- 34:15Yes.
- 34:15And it lets you pick different formatting guidelines.
- 34:19You can format via Pep 8 or Google or Facebook, like whatever their rules for how Python code should look.
- 34:25You can just make it look like that.
- 34:26That's pretty cool.
- 34:27I would guess you could extend it.
- 34:29Oh, yeah.
- 34:29I think you definitely can.
- 34:31I'm a huge fan of code formatting.
- 34:33It seems like a pretty nice sort of right before you check in type of feature.
- 34:38Just make sure you run that against your code always because there's always those weird like, why did this file change?
- 34:46Oh, it's just their formatting indented.
- 34:48My formatting unindents like war in the version control, right?
- 34:53And so having like something sort of stabilizing that, that's kind of cool.
- 34:56Yeah.
- 34:57And I think it helps normalize the look of code.
- 35:00So code is there for people to read, right?
- 35:03Like humans have to understand what your code is doing.
- 35:05And if you always know that certain line breaks are in certain places or stuff like that, I think it makes it a lot easier for people to actually interact with it.
- 35:15So I actually have, for most of my projects, I'll set up get hooks.
- 35:19So it's like a pre-commit hook that'll run the formatting and then also run any tests or anything like that to make sure that it didn't break anything.
- 35:27Yeah, that's a really cool idea.
- 35:28I like it.
- 35:29Yeah.
- 35:29Most of the stuff we've talked about so far really has to do with CPython, you know, the disassembly and the interpreter and stuff.
- 35:35But there's alternate interpreters as well, right?
- 35:38And that, of course, involves abstracts, syntax, trees as well.
- 35:41We talked a little bit about Python's speed.
- 35:44And so the best way to speed up CPython is actually to just completely switch out your interpreter.
- 35:51And so that's why there are a lot of interpreters like PyPy, Jython, Cython, the list goes on.
- 36:00And so you can actually use these other interpreters to run almost exactly the same syntax.
- 36:07So that is one of the downsides.
- 36:08So that is one of the downsides is that in order to make some of these optimizations, you have to have certain sacrifices in the way that your language is represented.
- 36:18So your AST is going to look a bit different in these different interpreters because a lot of them will try to make different optimizations and translations of that AST.
- 36:29Right.
- 36:29And so, like, for example, Cython would be totally different probably.
- 36:34But maybe PyPy is actually really similar.
- 36:37I think PyPy starts out the same as an interpreted CPython, but eventually if it finds a hotspot, it will replace it with a JIT compiled version.
- 36:45So maybe it starts out the same.
- 36:47I don't actually know.
- 36:48Yeah, I'm definitely not an expert on all the different interpreters.
- 36:51It's interesting, though.
- 36:53There's all these different tradeoffs and there's all these different interpreters trying to explore the advantages or disadvantages of something, right?
- 37:00Yeah.
- 37:01Another one you talked about was the Beware project.
- 37:04Is it PyB?
- 37:04Is that also from the Beware project?
- 37:06I know PyB is, like, their GitHub account, I believe.
- 37:09Yeah, yeah.
- 37:10There's a ton of projects under there, yeah.
- 37:12Yeah.
- 37:13PyB is doing some really, really awesome work in trying to use Python for, like, native mobile development.
- 37:20And so whether that is in the form of transpiling code in order to interact with native mobile components or actually they have a project called Batavia.
- 37:33I probably am butchering that.
- 37:35Yeah, yeah.
- 37:36That's right.
- 37:36That is their transpiler one.
- 37:38That's right.
- 37:38Yeah.
- 37:38So they're actually, they'll transpile Python into JavaScript as well.
- 37:43How interesting.
- 37:44Yeah.
- 37:44They definitely have some interesting stuff going on over there.
- 37:47I would love for that to become a thing.
- 37:49You know, like, proper native mobile apps in Python.
- 37:53Because right now, you know, I don't think there's a lot of great options.
- 37:57I know you can do some stuff with Pythonista, but it's kind of stuck within, like, that app, right?
- 38:03You can't just ship your own app to the app store.
- 38:05And I've been playing with Ionic framework and Electron.js and Cordova and all those things.
- 38:13And I would rather just not, you know.
- 38:14But right now, there's not a super awesome option.
- 38:17So it'd be cool if they were successful.
- 38:21This portion of Talk Python To Me has been brought to you by Rollbar.
- 38:24One of the frustrating things about being a developer is dealing with errors.
- 38:28Relying on users to report errors, digging through log files, trying to debug issues,
- 38:33or getting millions of alerts just flooding your inbox and ruining your day.
- 38:37With Rollbar's full stack error monitoring, you get the context, insight, and control you need to find and fix bugs faster.
- 38:43Adding Rollbar to your Python app is as easy as pip install Rollbar.
- 38:48You can start tracking production errors and deployments in eight minutes or less.
- 38:52Are you considering self-hosting tools for security or compliance reasons?
- 38:56Then you should really check out Rollbar's compliant SaaS option.
- 38:59Get advanced security features and meet compliance without the hassle of self-hosting,
- 39:04including HIPAA, ISO 27001, Privacy Shield, and more.
- 39:09They'd love to give you a demo.
- 39:10Give Rollbar a try today.
- 39:12Go to talkpython.fm/Rollbar and check them out.
- 39:17I think that being able to actually transpile into native code.
- 39:22So a lot of other platforms like Ionic, etc. will use WebViews.
- 39:27So you're still running a JavaScript app in your native application.
- 39:31Right.
- 39:32And you have all these performance issues.
- 39:34Like large lists are super weird unless you choose like virtual scrolling add-ons and all kinds of stuff, right?
- 39:40Yeah.
- 39:40And like animations are a lot harder.
- 39:42You just, you have that separation between your app and the bare metal.
- 39:47So you can't do a lot of like GPU optimizations.
- 39:50Yeah.
- 39:50So fingers crossed for a little bit more from the Beware folks.
- 39:54That'd be awesome.
- 39:55Another one that a lot of people likely interact with, especially from the Flask world, is Jinja2.
- 40:01Yeah.
- 40:01So that's one of the things like the more you start looking around at the tools that you're using, the more you realize that a lot of them are using ASTs under the hood to accomplish some really cool things.
- 40:12So, but it makes sense because, I mean, HTML in itself can be thought of in a tree structure.
- 40:17And so it's really easy to parse HTML into a tree.
- 40:21And then if you have variables in your Jinja template that need to be filled in, it's really easy to kind of pop those values in and then transpile everything back into an AST or into the HTML from the AST.
- 40:34The template languages are pretty impressive the way they work for all the different web frameworks.
- 40:39It's kind of cool to see them go.
- 40:41Yeah.
- 40:41And if you think about it, you can have little bits and pieces of Python code in your Jinja templates.
- 40:48And so you can kind of see how all this comes together where you've got an AST that you can then edit and kind of piece additional bits of code into the AST and then transpile it all back.
- 41:00Yeah.
- 41:00Yeah.
- 41:01It's definitely a cool example.
- 41:02So all those are kind of within the realm of Python.
- 41:05How about outside Python?
- 41:06There's a lot of different code analysis that you can do.
- 41:10Any sort of linting is usually going to use an AST under the hood.
- 41:13And then we already talked about Babel in the JavaScript world.
- 41:17There's also some really cool stuff that they're doing with CSS.
- 41:21So especially with the advent of all these newer JavaScript frameworks, there's a huge debate over how you actually handle your CSS and your styling now.
- 41:32So you can use an AST to do CSS transformations and really optimize the use of mixins and different media queries.
- 41:43And you can kind of automate a bit more than what you used to be able to.
- 41:47There's definitely a ton of that stuff over in the JavaScript web world.
- 41:50It's quite interesting.
- 41:51And all the minification and all types of stuff that happens before your code actually goes out to the web.
- 41:59Yeah.
- 41:59It's pretty cool.
- 42:00So what else would you like to sort of let people know about why you got some time to speak with them?
- 42:06One of the things that I have definitely been sort of reflecting on a lot recently is just going through my first time speaking at a conference.
- 42:14And so I think I mentioned I wrote a blog post on it.
- 42:17But I think that I want to kind of shed some light on what that process looks like.
- 42:22And for a lot of people, it's like, it's really intimidating to actually go out there and especially to start off with a technical talk.
- 42:30I think one of the really scary parts is I think a lot of people are afraid that when you get up in front of them,
- 42:35the audience is just going to find that little one thing you don't know and just tear into you because you didn't know.
- 42:42Well, actually, there's this one aspect of ASTs that does one thing.
- 42:45And I think one of the things I've learned about the Python community is that people are generally really supportive.
- 42:51And those types of things are not likely to happen unless you just have like really an unprepared presentation, I think.
- 42:59I've gotten some really great feedback.
- 43:00And I did have these little like, oh, well, you missed this little thing.
- 43:04But I really liked this, this, this, and this, you know.
- 43:07But I think I really urge people if you have a desire to speak at a conference to just do it and submit that proposal.
- 43:14And you might get accepted and you might not.
- 43:16But you also might get some really great feedback on your proposal.
- 43:19I think it can absolutely change your position within the community, right?
- 43:25Like once you've done one of these talks, like your talk is now on YouTube.
- 43:28If for some reason you ever wanted to apply for a job, it sounds like you're being super successful not having a boss.
- 43:34But if for some reason you wanted to, having that up there would be a really great resume item, right?
- 43:39You could say, do you want to know if I know about it?
- 43:42Look, here's me speaking for half an hour in front of hundreds of people doing it, right?
- 43:46Yeah.
- 43:47And it's also a really great way to like get accepted for other conferences too.
- 43:51So like as soon as you have that first conference talk, you can kind of point to that and be like, yeah, I can actually hold my own in front of a crowd and stand up on stage and not completely forget how to speak.
- 44:03I'm sure that's a concern for conference organizers and, you know, seeing someone who's obviously good at it is really, really opens doors, I would think.
- 44:12And it doesn't have to just be like the main PyCon, right?
- 44:16For example, PyCascades is a regional one.
- 44:19They're all over the world.
- 44:21But there's also meetups and user groups and smaller things, maybe even like a brown bag lunch talk at your company for the first type thing, right?
- 44:30Like here, I'm going to tell you guys all about like web scraping.
- 44:32Nobody knows about it here.
- 44:33So let's talk about it.
- 44:34Yeah.
- 44:34And I always kind of remind myself to go back to that.
- 44:37It's like a very, very well-known Venn diagram of like what you think everybody else knows and what you think you know and how there's really a lot less overlap in those spaces than you'd think and how much value you can really add.
- 44:52Even though you just kind of assume, oh, everybody else probably already knows this.
- 44:56Yeah, that's right.
- 44:57It's easy to assume that, but I find it's actually rarely the case.
- 45:01I used to do a lot of like in-person professional training and I would get on the phone to like set up some kind of event with the company I was going to.
- 45:10And the managers would also say, our developers are super advanced.
- 45:14They're really advanced.
- 45:15Like just no beginner stuff.
- 45:16We only want advanced stuff for them because they're the best.
- 45:19All right, great.
- 45:20You know, then we show up like, all right, we're just doing advanced stuff.
- 45:22But hold on.
- 45:23Can we talk about this not advanced stuff for like a day or two?
- 45:26Because nobody knows it.
- 45:28Like, what do you mean nobody knows it?
- 45:29Like your manager just told me that, all right, great.
- 45:32That's what I actually believe was the case.
- 45:33But, you know, you don't want to tell that to people, right?
- 45:36But I think there's a lot of value in sort of some of the foundational stuff for sure.
- 45:39Yeah, absolutely.
- 45:40Yeah.
- 45:40So I think there's a bunch of opportunities for people to speak.
- 45:42And it's also, you can kind of level up, right?
- 45:44Like you do a talk at a user group and then that gives you the confidence to do a talk at like a regional conference.
- 45:49And then you can do, you know, whatever else you want to do.
- 45:52I was very pleasantly surprised at how rewarding it was and how validating it was that like me going from somebody who has like a very technical theoretical background and being kind of mildly obsessed with ASTs and learning about CPython's compiler and interpreter.
- 46:10And then being like, oh, yeah, I'm going to give a talk on this and having people be interested in it and want to talk about, you know, their perspectives and interests.
- 46:19So one of the things that I gained from doing this talk is seeing all the dozens of different interpretations and interests that people had that this talk sparked for them, which was really interesting.
- 46:31Yeah.
- 46:32Yeah.
- 46:32That's really rewarding.
- 46:33I guess last thought on this one is how much time did it take you to prepare this whole half hour presentation with all the research and everything?
- 46:41Like what kind of commitment was it?
- 46:43Yeah.
- 46:43I put 30 plus hours easy.
- 46:47So that's like more than 10 times.
- 46:50It was 30 minute talk.
- 46:51So 60 times.
- 46:53Yeah.
- 46:53That's it still seems about right because it's a lot of research and your talk was really well put together.
- 46:59So, yeah.
- 47:00And that's just so that's just the talk preparation itself.
- 47:04So I've been kind of iterating on my own like side research into CPython for.
- 47:10Oh, geez.
- 47:11Probably almost a year now.
- 47:13Maybe over a year.
- 47:16So there's definitely a lot of a lot of research that's gone into it.
- 47:20A lot of, you know, shower thoughts and all that stuff.
- 47:22Yeah.
- 47:23Yeah.
- 47:23Sure.
- 47:23Well, like I said, it was really good talk.
- 47:25We'll link to it from the show notes.
- 47:28People can go watch it.
- 47:29I think they just have like two whole days of video.
- 47:32So I have a timestamp in the link.
- 47:34So hopefully it starts playing.
- 47:35But if for some reason it doesn't, it's like two hours and 45 minutes into day two or something like that.
- 47:42But yeah, it was a really, really good talk.
- 47:44And I'm glad you gave it there.
- 47:46Thank you.
- 47:46I'm glad to have given it.
- 47:47Yeah.
- 47:48So let me hit with the final two questions before I let you out of here.
- 47:53First, if you're going to write some Python code, what editor do you use?
- 47:56I always use Sublime on a daily basis.
- 48:01I'm also really comfortable in VI and Vim just because I did a lot of sort of server management.
- 48:07So I can get around there.
- 48:09But I am a huge fan of Sublime's Anaconda package.
- 48:14Oh, that is really nice.
- 48:15Yeah.
- 48:15Yeah.
- 48:15That's not the regular.
- 48:16That's not Anaconda as in the NumPy scientific world.
- 48:20It's a totally different thing.
- 48:21Maybe tell people about it.
- 48:22It kind of brings a little bit of like the IDE experience to Sublime and allows you to
- 48:29highlight, you know, where a function is defined and that kind of stuff.
- 48:33Yeah.
- 48:33It's really a really nice add on for it.
- 48:35That's cool.
- 48:35And notable PyPI package.
- 48:38We talked about a bunch.
- 48:39Let's grab one of those or another one.
- 48:41Yeah.
- 48:41I think the one that I always have to talk about when people ask me this is the request library.
- 48:48So I think that was the first Python code that I saw that I was like, wow, this like it felt Pythonic to me.
- 48:56Like I was like, this is how interacting with a package should feel.
- 49:00And I think that Kenneth Reed always does a really excellent job of thinking about your package's API.
- 49:08All of your code and your classes and all that have an API that humans have to interact with.
- 49:12I love that that's a theme for all of his work.
- 49:15Yeah.
- 49:15The tagline, all of his stuff is for humans.
- 49:17Requests is for humans.
- 49:19And then records is like SQL for humans and all sorts of stuff.
- 49:22Yeah.
- 49:23Yeah.
- 49:23Definitely good stuff.
- 49:24He's doing really, really good work.
- 49:25All right.
- 49:26So final call to action.
- 49:28People are excited about the stuff.
- 49:29They want to learn more.
- 49:30I mean, obviously they should check out your talk, but what else can they do to get started?
- 49:34That is a great question.
- 49:36I would encourage people to find the way that they want to apply ASTs.
- 49:43So whether that's in linting or code highlighting or actually like getting in there and messing around with ASTs and find something that is like a really small thing that you can tweak and have fun with and see how you can actually improve your current workflow.
- 49:59Yeah.
- 49:59That sounds awesome.
- 50:00All right.
- 50:00Well, Emily, thank you so much for being on the show.
- 50:03It was great to chat with you and thanks for sharing your AST project with us.
- 50:07Thank you.
- 50:07Yep.
- 50:07Bye.
- 50:09This has been another episode of Talk Python To Me.
- 50:12Today's guest was Emily Morehouse.
- 50:15And this episode has been brought to you by ParkMyCloud and Rollbar.
- 50:18Do you hear that sucking noise?
- 50:20That's your cloud provider making you pay for your idle instances.
- 50:24Turn on ParkMyCloud, plug the leaks and save money.
- 50:27Visit talkpython.fm/park to get started.
- 50:30Rollbar takes the pain out of errors.
- 50:33They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain, of course.
- 50:41As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash talkpythontome.
- 50:48Are you or a colleague trying to learn Python?
- 50:51Have you tried books and videos that just left you bored by covering topics point by point?
- 50:56Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course to experience a more engaging way to learn Python.
- 51:04And if you're looking for something a little more advanced, try my Write Pythonic Code course at talkpython.fm/pythonic.
- 51:13Be sure to subscribe to the show.
- 51:14Open your favorite podcatcher and search for Python.
- 51:16We should be right at the top.
- 51:18You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 51:27This is your host, Michael Kennedy.
- 51:29Thanks so much for listening.
- 51:30I really appreciate it.
- 51:31Now get out there and write some Python code.
- 51:33I really appreciate it.