Latest / Talk Python To Me / #340: Time to JIT your Python with Pyjion?
Transcript
- 0:00Is Python slow? We touched on that question with Guido and Mark in the last episode.
- 0:04This time, we welcome back friend of the show, Anthony Shaw. He's here to share the massive
- 0:09amount of work that he's been doing to answer that question and speed up things where the answer
- 0:13is yes. And he just released version one of the Pigeon project. Pigeon is a drop-in JIT compiler
- 0:21for Python 3.10. It uses the .NET 6 cross-platform JIT to compile and optimize Python code on the fly
- 0:29with zero changes to your source code. It runs on Linux, macOS, and Windows, both x64 and ARM64.
- 0:36It's a cool project, and I'm excited Anthony's here to tell us all about it.
- 0:39This is Talk Python To Me, episode 340, recorded November 3rd, 2021.
- 0:58Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy. Follow
- 1:03me on Twitter, where I'm @mkennedy, and keep up with the show and listen to past episodes at
- 1:08talkpython.fm. And follow the show on Twitter via at Talk Python. We've started streaming most of our
- 1:14episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube to get
- 1:20notified about upcoming shows and be part of that episode. This episode is brought to you by Shortcut
- 1:26and Linode, and the transcripts are sponsored by Assembly AI. Anthony Shaw, welcome to Talk By The
- 1:34Enemy.
- 1:34Hi, Michael. Good to see you again.
- 1:35Yeah, it's great to have you back. You're at least yearly appearance here. If not by name,
- 1:41you know, you have at least appear yourself once. But I think you get mentioned a bunch of times with
- 1:46all the stuff you're doing.
- 1:47Yeah, we're just trying to work out when there's the last time. It's like a year, over a year ago.
- 1:51Yeah, yeah, it was May 2020. See, that was when the whole COVID thing was about to end. Like,
- 1:58hey, it's just a couple of months. We'll be through this. It'll be fine. Everyone will wear their mask
- 2:01and get their shots and it'll be totally normal.
- 2:03I had to pause for a second. I was trying to work out what year it was.
- 2:08I know. I know. Well, you're in Australia, so it's probably the next year.
- 2:122022, yeah.
- 2:13Yeah, you guys are always ahead by a little bit.
- 2:15Yeah, exactly.
- 2:16Awesome. Well, welcome to the show. This time we're here to talk about a project that you've
- 2:21been spearheading for the last year or so, Pigeon, which is a JIT compiler for Python,
- 2:27which is pretty awesome.
- 2:29Yeah, I kind of, it was sitting on the shelf for a few years and I decided to pick it up. It was
- 2:35related to a thread of things that I've been working on, looking at Python performance. And also
- 2:39when I kind of finished working on the book, so.
- 2:42The CPython internals book, yeah.
- 2:44CPython internals book. Yeah, it was like really interesting to dig into a compiler and I really
- 2:50wanted to put some of that theory into practice and work on my own compiler. So yeah, that's kind
- 2:56of what led into it.
- 2:57It looks like no small feat as people will see as we get into it, but how much did the diving into
- 3:02the C internals make you feel like, all right, I'm ready to actually start messing with this and
- 3:06messing with how it runs and, you know, compiling stuff to machine instruction. Yeah.
- 3:11Yeah, massively. I don't know where I would have started otherwise. It's a pretty steep learning
- 3:15curve.
- 3:15Yeah. If someone gave me that job, I'd be like, I have no idea how to do this.
- 3:19Yeah. I was one of those projects I got started on because it just had my curiosity. I didn't
- 3:24understand how it could work and yeah, I just really wanted to learn and it just seemed like
- 3:29a really big challenge. So yeah, I looked at it and thought this is an interesting thing.
- 3:33I know that Brett and Dino were no longer working on it and just decided to pick it up and see how
- 3:38far I could take it.
- 3:38Yeah, absolutely. I think you've taken it pretty far and it's about to go to 1.0. Is that right?
- 3:45Yeah. So it could be launching version 1.0 of Pigeon in a few days. So I'm waiting for .NET 6 to be
- 3:53released and I'll explain why probably a bit later.
- 3:56Wait, wait, wait, wait, wait, wait, wait, wait, wait, hold on, hold on. This is the Python project
- 4:01on a Python podcast and you're waiting for .NET 6? Oh my gosh, I don't understand.
- 4:04Yeah, this bit confuses people and it did originally, I think when the project was written. So
- 4:10it's a JIT compiler for Python written in C++ and you could write your own JIT compiler,
- 4:18which is no small feat.
- 4:20Yeah. And then you'd be done in like 10 years.
- 4:22Exactly. Or you can take a JIT compiler off the shelf. So a JIT compiler compiles some sort of
- 4:28intermediary language into machine code. So assembly. A lot of JIT compilers are working with basically
- 4:36like which registers to use, which operations and instructions are supported on different CPUs.
- 4:42There's a whole bunch of stuff to work on. Very, very involved. And .NET Core, what was called .NET Core,
- 4:50now just .NET, has a JIT compiler in it. And yeah, you can actually use just the JIT compiler.
- 4:57So that's what the project originally did was to basically use the JIT compiler for .NET Core.
- 5:04Other JITs for Python, some of them use the LLVM JIT. And there's a few other JITs as well you can get
- 5:10off the shelf. So yeah, I started to use the .NET one. That was originally Dino and Brett when they
- 5:16built this. It was actually before .NET Core was even released. It was still in beta back then,
- 5:20but the other used .NET Core's JIT.
- 5:22Yeah. I think it was a much earlier version of .NET Core back then, right? Like it's come a long way.
- 5:28I think back then, you probably know this better than I do now, but back then I think there was like
- 5:33a fork in the road to pass for the .NET world. You could do traditional .NET on Windows only,
- 5:41but that was like the 15-year polished version of .NET. And then there was this alternative,
- 5:47funky, open source .NET Core thing that sort of derived, but was not the same thing as that.
- 5:54And so I think probably when Brett and Dino were working on it, it was really early days on that
- 5:58version of the JIT compiler.
- 6:00Yeah, it was version 0.9 of .NET Core.
- 6:02Right.
- 6:02So yeah, I did actually get involved back then at just helping out, upgrading it from version
- 6:080.9 of .NET Core to version one. So I did like help on the original Pigeon project with some of the
- 6:15builds and stuff, but that early version of Pigeon required a fork of CPython and a fork of .NET Core.
- 6:22So it required you to compile both projects from source with patches and like stick a whole bunch
- 6:29of stuff together. And yeah, very tricky to set up. And that's one of the things when I kind of came in
- 6:34a year ago to pick this project up again, that I really wanted to tackle was let's make it easy
- 6:39to install this, which means it should just be pip installable. So you can just pip install Pigeon
- 6:45on Python. And that's the second thing I had to do was to upgrade it to the latest versions of Python,
- 6:50the latest versions of .NET. So yeah, it's running on .NET 6 and CPython 3.10. So yeah,
- 6:58it's basically a JIT compiler for Python 3.10.
- 7:01Right. So now we have .NET is, I think they've closed that fork. It's a little bit like the two
- 7:07to three boundary that we've crossed. It's just back to this .NET thing and it's open source,
- 7:12which is cool. So that closes the .NET JIT side of things from a beta thing. On the other hand,
- 7:19there's a PEP and you'll, I'm sure you know the number. I don't know the number off the top of my head
- 7:24that allowed for extensions into standard CPython. So you don't have to fork it and reprogram
- 7:32ceval.c. There's an extensible, an extensibility layer for this kind of stuff now, right?
- 7:38Yeah. So maybe to backtrack a little bit, but when you write Python code and then execute it
- 7:42in CPython, which is the most popular Python interpreter, the one you get from Python.org,
- 7:47when you compile the, well, you don't compile the Python code. Python does it for you.
- 7:52When you compile Python code, it compiles down into an abstract syntax tree. And then the next level
- 7:59down is a bytecode sequence, which you can see if you import the disk module and you run the disk
- 8:06function on your code. I've got to talk about Pidgin, which I did at PyCon this year.
- 8:12Yeah. We'll link to that in the show notes. Yeah.
- 8:13Yeah. So it gives some explanations and examples. So that's kind of the bytecode. And yeah, basically
- 8:20this looks at how can the bytecode gets handed off onto an evaluation loop in Python, which is called
- 8:28a ceval.
- 8:29Is that one of the first things you looked at when you started diving into the c source code? Is that
- 8:34the first file you went to?
- 8:35I was one of, yeah. It's such a big one. I remember on Python bytes last week, you mentioned that
- 8:42Łukasz had been analyzing bits of Python that changed the most. And that was like the most changed bit of
- 8:48Python. It's kind of like the brain of Python, really. It's the loop that evaluates all the
- 8:52instructions and then calls all the different C APIs to actually make your code do things.
- 8:58And what you can do in this PEP, which Brett proposed when originally when he was working on
- 9:04Pidgin, was that you can actually tell cPython to not use its own evaluation loop, but use a
- 9:10replacement one. So this PEP 523 it is, you can basically write an extension module for Python
- 9:17and then say, okay, from now on, I will evaluate all Python code. Well, Python compiles it for you and
- 9:25then just gives it to you as a bytecode code object with bytecodes in it. And then you can write a custom
- 9:31function which will evaluate those bytecodes.
- 9:34Right. Exactly. Normally there's just a switch statement that says, if I get this bytecode,
- 9:38here's what I do. If I get that bytecode, here's what I do.
- 9:41One of the drawbacks of that, that makes it super hard to optimize, among other things, is it's one
- 9:47statement at a time, right? Like the C of L dot C, that switch statement, that loop doesn't go,
- 9:53here's a series of possibly related opcodes, make that happen. It goes, no, you need to load this
- 10:01variable. Now create this object. And there's just not a lot of room for optimization there,
- 10:07right? You're not going to inline a function or do other types of things when it's, you know,
- 10:10instruction by instruction.
- 10:12Yeah, exactly. So what Pidgin does essentially is it implements that API. When you install Pidgin
- 10:19and activate Pidgin, which you do by importing Pidgin and then just doing Pidgin dot enable,
- 10:24it will tell CPython that Pidgin will be the function to evaluate all Python code from now on.
- 10:31And when it sees a new function for the first time, instead of interpreting all the bytecode
- 10:37instructions, when you execute the function, it will basically interpret those ahead of time and
- 10:43then compile them into machine code instructions and then store that machine code in memory and then
- 10:50re-execute it every time you run the function. So it basically compiles the function down into
- 10:56assembly, essentially, and then puts that assembly object in memory. And then when you run the Python
- 11:03function, if it's already been compiled, it will then just run those instructions.
- 11:07Right. As standard JIT stuff, it has to do it once. But then once it's hit one method, it's like,
- 11:13okay, this one, here's the machine instructions for it. We're just going to reuse that, right?
- 11:17Yeah, because the computer needs machine code to do anything. So something has to have compiled it
- 11:24down into machine code. And in the case of normal CPython, CPython is written in C and the C compiler
- 11:30has compiled that down into machine code. But it's a loop that it runs through for each bytecode
- 11:36instruction to go, okay, this is a add operator. So, you know, I'm going to take two objects off the
- 11:43stack, the left-hand side and the right-hand side, and then I'm going to call the add function in the
- 11:48C API.
- 11:48Right. Exactly. I kind of got you diving down deep a little too quick. I do want to set the stage just
- 11:54a moment before we get into how all of this works. Because understanding where you're coming from and
- 12:01understanding some of the problems you're trying to solve are really going to be helpful to seeing
- 12:05the value here. So back in, what was it, April of 2020, whatever PyCon was, that virtual PyCon,
- 12:13the first virtual PyCon, you had that talk called Why Python is Slow. And you talked about some
- 12:18interesting things that really set the stage for, well, if you had a JIT and you had all sorts of
- 12:23control over it, as you do, how could it be faster? What could we do, right? So one of the things you
- 12:27talked about was this in-body problem, how C++ relative to say Python, there was a bit of a
- 12:33difference there, but also .NET Core was a lot faster. And really importantly, JavaScript was
- 12:37faster, right?
- 12:38Yeah. So that was 2019.
- 12:41My gosh. Okay.
- 12:43Yeah. This is part of this lovely pandemic. So yeah, I covered the in-body problem, which is
- 12:49interesting because it's not a, the in-body problem is a mathematical formula that calculates
- 12:55the position of the jovial planets.
- 12:59And as soon as you have three or more, it starts to get super complicated, right?
- 13:02Yeah. It's basically like a big mathematical formula and it just loops through the iterations
- 13:07to work out the position of different planets. So it's, it's kind of the difference between C is
- 13:13seven seconds it takes to run the algorithm in C and 14 minutes it takes to run it in Python.
- 13:18Python's even slower than Perl, which isn't embarrassing.
- 13:21That's a little embarrassing. Yeah. It's actually pretty much the worst case scenario for all
- 13:27the reasonable languages. Yeah.
- 13:28In that talk, I dug into the details about why some of the reasons why that is. And kind of the core of
- 13:34the in-body algorithm is this, is a few lines of code, which basically calculate, look at floating
- 13:40point numbers and it calculates, does the big calculation. So there's a lot of mathematical
- 13:45operations. There's like minus divide power add, which is great. And it can all be done in line.
- 13:51CPUs are very efficient at doing this because CPUs natively understand floating point numbers.
- 13:58Yeah. But a number in C and a number in Python, these are not equivalent, right? A floating point
- 14:03number in C is probably eight bytes on the stack. A floating point number in Python is a, what is that?
- 14:09A PI float object that's 50 bytes and is out on the heap, probably separated in space from the other
- 14:15numbers in terms of like, it'll cause more cache misses and flushes and all sorts of stuff, right?
- 14:21Yeah. So a floating point number in Python is a, is an immutable object and it's basically a wrapper
- 14:28around a double. So yeah, basically you have to create a Python object to store the floating
- 14:35point number. And then if the value changes, you have to create a new one. So the issue in N body
- 14:40is that you have to create for one, one line of Python that just does a whole bunch of work to get a
- 14:46single answer, like a single floating point number, all the interim values in that calculation create
- 14:52like 18 objects, which are immediately discarded.
- 14:55Right, right, right. So the memory management kicks in just constantly. Yeah.
- 15:00Yeah. And Python is pretty efficient at allocating small objects, but when you magnify that to the
- 15:06level that is seen in the N body problem, then yeah, that's why it's so slow effectively because
- 15:11it's creating all these temporary objects and then destroying them in the next operation.
- 15:19This portion of talk Python to me is brought to you by shortcut, formerly known as clubhouse.io. Happy
- 15:25with your project management tool. Most tools are either too simple for a growing engineering team to
- 15:30manage everything or way too complex for anyone to want to use them without constant prodding.
- 15:35Shortcut is different though, because it's worse. No, wait, no, I mean, it's better.
- 15:39Shortcut is project management built specifically for software teams. It's fast, intuitive, flexible,
- 15:45powerful, and many other nice positive adjectives. Key features include team-based workflows.
- 15:50Individual teams can use default workflows or customize them to match the way they work.
- 15:55Org wide goals and roadmaps. The work in these workflows is automatically tied into larger company
- 16:01goals. It takes one click to move from a roadmap to a team's work to individual updates and back.
- 16:07Type version control integration. Whether you use GitHub, GitLab, or Bitbucket, clubhouse ties directly into
- 16:13them so you can update progress from the command line. Keyboard friendly interface. The rest of
- 16:18shortcut is just as friendly as their power bar allowing you to do virtually anything without
- 16:24touching your mouse. Throw that thing in the trash. Iteration planning. Set weekly priorities and let
- 16:29shortcut run the schedule for you with accompanying burndown charts and other reporting. Give it a try over at
- 16:36talkpython.fm/shortcut. Again, that's talkpython.fm/shortcut. Choose shortcut because you shouldn't have to project manage your project management.
- 16:46One of the things you can do is maybe understand that there are numbers there and treat them.
- 16:53Keep, say, the intermediate values as floating points and only return the result to Python.
- 16:58Like, okay, this Python runtime is going to need a pyint or a pylong or a pyflow or whatever, but we don't need to do all the intermediate steps that way.
- 17:09We could compute those in a lower level thing because we, again, understand the whole function, not just understand, you know, multiply two numbers,
- 17:17multiply two numbers, add two numbers, but like that whole thing as a group, right?
- 17:21Yeah, exactly. So the principle behind some of the design ideas in Pidgin is that, and in lots of other compilers, this is not something I came up with. But the idea is to try and keep things as efficient as possible by just carrying
- 17:36values on the CPU registers and then not allocating memory in the heap. And a floating point number fits in a CPU register.
- 17:44So a 64-bit integer or a floating point number fit in a CPU register. So let's just carry those values on the registers and then do low level instructions to do addition and minus and multiplication as well, but not divide.
- 17:59Because I found out Python has a whole bunch of like custom rules for division.
- 18:05Yeah.
- 18:06Yeah.
- 18:06So I can rely on the CPU instructions to do that.
- 18:09So these are the types of things that you're like, well, maybe we could use this PEP 523 and some kind of JIT compiler and turn it loose on this.
- 18:19I just earlier this week interviewed Guido and Mark Shannon about just general Python performance.
- 18:26They're working on sort of a parallel branch of making Python faster, which is great.
- 18:31So out of the live stream, Josh Peake asks,
- 18:33Mark Guido teased the potential of addition of a JIT to CPython 3.13.14.
- 18:39Would this potentially intersect with that project?
- 18:43Is this totally separate?
- 18:44Do you have any visibility there?
- 18:45Yeah, I haven't asked to be involved in that yet.
- 18:48I don't know if, I mean, Mark Shannon's experience with compilers is like miles ahead of mine.
- 18:56And to be frank and, and, and, you know, Guido has invented the language.
- 19:00So like their knowledge surpasses quite substantially.
- 19:03Yeah.
- 19:04I hope that the work done in this project will be insightful when they're designing the JIT.
- 19:10And I've already spoken to both of them about this project and walk through like what's working and what isn't.
- 19:17And cause it's, I guess, quite a bit ahead and it's dealing with some challenges, which they're probably going to hit when they come to this.
- 19:23And then yeah, it will, it will steer, steer them in that direction.
- 19:26Cool.
- 19:26Let's talk about compiling just for a bit, because I did a lot of C++.
- 19:31I remember pressing compile the build button or the run, which would build in a run and you would see it grind.
- 19:38And actually thinking back, that was when computers actually made noises.
- 19:42They would like, you know, like their hard drive would like make noises that they are, they, you would hear it compiling even.
- 19:48Yeah.
- 19:49Also in C#, .NET compile, but less and much faster.
- 19:53But in Python, it's just, it runs.
- 19:55It feels like it just runs.
- 19:56And I don't remember this compile step.
- 19:58And yet there is a, there is an aspect of compiling, right?
- 20:01Yeah, it happens.
- 20:02You just don't see it.
- 20:03So yeah, it happens behind the scenes.
- 20:04It compiles it, but it doesn't compile it into machine code.
- 20:07It compiles it into bytecode.
- 20:09Right.
- 20:09Which is the same as .NET and Java.
- 20:11But the difference is what happens to that bytecode next, right?
- 20:14Yeah, it is similar, but the Python bytecode is, is much higher level.
- 20:19So there's like single operations for just add two objects, for example.
- 20:24Right.
- 20:24Or put this thing in a list.
- 20:25Yeah.
- 20:25Like add this thing to a list or merge two dictionaries.
- 20:28It's like dict merge is, is a single bytecode instruction.
- 20:32Whereas .NET uses a specification.
- 20:35It's an open specification called ECMA 335.
- 20:39And this specification describes different stack types.
- 20:44So it says, you know, there's like a 32 bit integer, 64 bit integer, 16 bit, et cetera.
- 20:51There's floating point numbers, which come in the form of four byte, eight or four or eight
- 20:58byte floating point numbers.
- 21:00And there's also things like Booleans and then how branches and evaluations work.
- 21:05So it's closer to assembly.
- 21:08But the reason you don't want to write things in assembly is because assembly is specific to a CPU.
- 21:12And you often find yourself writing instructions, which would only work on that particular CPU.
- 21:18And then when you ship it to the real world, like that doesn't work.
- 21:21Right.
- 21:22One of the big benefits of JIT is it can look exactly at what you're running on and say,
- 21:26oh, this has this vectorized hardware thing.
- 21:29So let's use that version here.
- 21:31Or this has this type of threading.
- 21:33So we're going to do some sort of memory management around that.
- 21:37C and C++ are ahead of time compilers.
- 21:39They will interpret your code, parse it and compile it down into machine code instructions,
- 21:45and then put it in a binary format, like a shared library or a standalone executable.
- 21:50.NET Java and other languages that have a JIT, they have both a compiled VM, which is something
- 21:59which has actually been compiled into a standalone executable, which is the framework.
- 22:03So the, you know, the Java.exe, for example.
- 22:06And then it could compile down the code into an intermediary language and then evaluate that
- 22:12just in time, and then typically cache the machine code onto a disk or into memory.
- 22:19And it does that using a JIT.
- 22:21And Python, CPython interprets everything at runtime, essentially.
- 22:27So it does cache the bytecode, but it doesn't cache the machine code because it doesn't compile
- 22:32to machine code.
- 22:32And that's what Pigeon does.
- 22:33Right, exactly.
- 22:34If you've seen PYC files with the Dunderpy cache, right, down in theirs, that's the compiled
- 22:41output of Python.
- 22:41But like you said, it's much higher level and it gets interpreted after that.
- 22:45Yeah.
- 22:45Yeah.
- 22:46So part of the insight of Pigeon is like, well, let's take that compile step.
- 22:52And instead of outputting Python bytecode, what if we output intermediate language bytecode?
- 22:58Because there's a nice compiler hanging around that can compile that.
- 23:01If you could somehow feed it that IL instead of PYC content, right?
- 23:06Yeah.
- 23:06So the steps are, it's quite involved.
- 23:09Yeah.
- 23:10The steps are, and I do go to this in the talk, but Python code, abstract syntax tree, code object,
- 23:16which has Python bytecode.
- 23:18And then Pigeon will basically compile Python bytecode into .NET intermediary bytecode.
- 23:25And then .NET will compile the intermediary bytecode into assembly, into machine code.
- 23:30And then you attach that to say the function object or a class or something like that, right?
- 23:35Yeah.
- 23:35And then that bytecode is, that machine code, sorry, is essentially an executable, which lives
- 23:40in memory.
- 23:41And then when you want to call it, you just call that memory address and it runs the function.
- 23:45Just in the same way that you would load a shared library and just call the address.
- 23:51Right.
- 23:51Right.
- 23:52You might have a .so file and you import it and run it.
- 23:55And as far as you're concerned, magically, it just runs, right?
- 23:58Exactly.
- 23:58Okay.
- 23:59Is it slow?
- 24:00The compilation step in particular, not necessarily, we'll get to the performance of the overall
- 24:04system.
- 24:05But like, is this JIT step, is this a big deal?
- 24:08Does it take a lot of memory?
- 24:09What's it like?
- 24:09Yeah.
- 24:10I haven't actually focused too hard on the performance of the compilation step because
- 24:13a lot of the problems that I'm looking at are compile once, execute 50,000 times.
- 24:19And the overhead doesn't really matter that much.
- 24:23Although it's pretty fast.
- 24:25I've been really impressed.
- 24:26Pigeon is written in C++ and the compilation step is actually pretty quick.
- 24:32The overhead is 10 to 15% of the execution time on the first pass, depending on the complexity
- 24:39of the function.
- 24:39But yeah, like if the function takes a second to run, then, you know, 0.15 of a second is
- 24:45around how much it'll take to compile it.
- 24:48Yeah.
- 24:48That's not bad.
- 24:49And then it goes faster.
- 24:50Yeah.
- 24:50And then once it's done it once, that's it.
- 24:53With the exception that Pigeon has a feature called profile-guided compilation, which is
- 24:58kind of something that I designed to get around how dynamic Python is.
- 25:05So JIT compilers are brilliant when you've got statically typed languages.
- 25:09So if you know that this variable is an integer and this variable is a string and this variable is
- 25:13an object, then you can compile all the correct instructions.
- 25:17But in Python, variable A could be assigned as a string and then changed to an integer and then
- 25:24you can assign it to the return of a function, which could be anything.
- 25:27So one of the challenges I kind of looked at was how do you actually make a JIT is only going to be
- 25:32faster if you've got optimizations and you can't make optimizations if you have to generalize
- 25:37everything.
- 25:37Yeah.
- 25:38So what it does is a feature called PGC, which it will compile a profiling function.
- 25:44So the first time it runs the Python code, it's basically going to sort of look at what variables
- 25:50are.
- 25:50It's almost like you're doing a C profile on itself.
- 25:54Yeah.
- 25:54So basically it compiles a function that runs and then when that function is running, it
- 25:59kind of captures a whole bunch of information about what's actually happening.
- 26:03And then it makes some assumptions and says, oh, you, when you were adding these three variables
- 26:07last time, they were all integers.
- 26:09So let's optimize that for integers next time.
- 26:12And if they do change, then it depends.
- 26:15It won't crash.
- 26:17What happens if they change?
- 26:18Okay.
- 26:18A crashing is an option.
- 26:19You probably don't totally want to go with the crashing part, but that might be a an intermediate,
- 26:24like we're building it and it's getting dialed in.
- 26:27Yeah.
- 26:27Some options that come to mind is you could have a, an alternate compiled version that says,
- 26:33okay, we've also seen this come as a string and, and so we're going to compile a separate
- 26:37one and then do like a lookup on the arguments and go from there.
- 26:41Yes.
- 26:41So they're called specializations and that's something that Mark Shannon talked about.
- 26:46And I think when CPython does its own JIT, they will definitely have specializations.
- 26:50The downside is extremely, and the downside is that you have a lot of memory overhead if there
- 26:57are lots of specializations.
- 26:58And a good example would be in the unit test module, the assert equal function.
- 27:03This is pretty much the first one I kind of slammed into like Pigeon tried to optimize the
- 27:09assert equal function, which could take anything.
- 27:12Like it could take two strings, a string and a number.
- 27:14Yeah.
- 27:14Yeah.
- 27:15Probably the first question is, are they the same type or can they be coerced in the same
- 27:18type?
- 27:19Yeah.
- 27:19And then just keep going down like these different cases.
- 27:22It can't be simple.
- 27:22Yeah.
- 27:23And it was actually in a conversation with Guido, he suggested looking at type guards.
- 27:28So the type guard is, so before I go into the optimized code, it will check to see, has the
- 27:36variable changed from what it was last time it got profiled?
- 27:40And then if it has changed type, then it will default back into a generic path.
- 27:45So that's essentially how it deals with different types.
- 27:49Yeah.
- 27:49One of the fall through paths could be just, well, let Python have it, right?
- 27:53Let Python just run the bytecode.
- 27:54Yeah.
- 27:55There are some things that Pigeon doesn't support.
- 27:57Async and await is one major, major feature.
- 28:00If it comes across asynchronous generators, then it will just hand them back to Python and Python
- 28:05executes them.
- 28:06It should be in there though, right?
- 28:07I mean, C# and .NET also have async and await.
- 28:10I know that means quite a bit differently, but theoretically in a future down the road,
- 28:14when you have more time, maybe it's not completely out of the world possible.
- 28:18I actually kind of started implementing it and put most of it together, only to realize that
- 28:23the APIs for asynchronous generators are all private in CPython.
- 28:28So I can't import them, which makes it technically impossible to implement, which is a bit of a
- 28:33shame.
- 28:34But yeah, that's one of the drawbacks at the moment is you can't do async and await.
- 28:38Right.
- 28:39But if this were super successful, I can see that that's like, okay, well, let's go ahead and expose
- 28:44that because Anthony's so close.
- 28:45Yeah.
- 28:47They could probably maybe be coerced.
- 28:49It's like a one line code change, I think.
- 28:51Yeah.
- 28:51Now this doesn't apply to the profile guided optimizations, but one of the things that
- 28:58these frameworks have, you know, I know that .NET has had it at several levels, like they've got this
- 29:03NGen utility that will take a .NET assembly in IL and you can pre-compile it like ahead of time, compile it
- 29:11and generate a native image on your machine.
- 29:13And then Xamarin had that because they had to have something like this to get onto iOS where they
- 29:19pre like ahead of, they ran the JIT compiler in advance and saved it.
- 29:23Is that something that could potentially be done here?
- 29:25Or is it, is it too much?
- 29:27I watched this space.
- 29:28I've been researching that.
- 29:31That's kind of one of the things I've been looking into is, can you compile it down into a
- 29:37format which can be stored and then loaded or marshaled?
- 29:41Or can it be stored into a portable executable format or some other binary format?
- 29:47Lots of security implications there as well.
- 29:49So that's one thing I'm cautious of.
- 29:51But yeah, I want to look into.
- 29:53Yeah, I hadn't even thought about all the challenges you got there.
- 29:55Yeah, that could be interesting.
- 29:57But you know, if it comes along that, yeah, this is pretty good, but there's this slower startup.
- 30:03And I know something that the core devs and, you know, have been very protective of is the startup
- 30:08speed of Python, right?
- 30:10That they don't want it to start super slow because often it's, it's sort of run on a little tiny bit of
- 30:16do this tiny thing and then we're going to drop back and then maybe run Python again on this tiny
- 30:20thing or even mic, multi-processing, you know, fork it, run these things, drop out of it.
- 30:25So I'm just thinking of like, how do you protect, like, how do you still achieve that goal and gain these advantages?
- 30:32Yeah, I think there probably could be work done to make the compiler more efficient.
- 30:35Also, you can set the threshold of how many times should a function be called before you JIT compile it.
- 30:41Right.
- 30:41So that's the threshold setting.
- 30:43So if you call a function once, there's probably no need to JIT compile it.
- 30:47Well, there's, there is no need to JIT compile it because, you know, you're compiling and then
- 30:52just running it straight afterwards.
- 30:53Whereas if it gets called a lot, then you would, you would want to call it a lot.
- 30:56So, and that's kind of where you get these sort of things, your hot functions, which is
- 31:00a function, which is run a lot.
- 31:02You want to specialize and make more efficient essentially.
- 31:07So yeah, if you are like sorting a list, for example, then doing comparisons between two
- 31:13different types, you'd want to make that as efficient as possible.
- 31:16And that would inherently make sorting algorithms all quicker.
- 31:19For sure.
- 31:19Yeah.
- 31:20So there's multiple stages here, right?
- 31:23There's the uncompiled code or letting Python run the code.
- 31:26Then there's compiling it with those hooks to understand what types come in for the specialization.
- 31:31And then there's the generate, generating the optimized version.
- 31:35So if it's run once at best, you'll get the unoptimized compiled version and unoptimized
- 31:41compiled code is probably not that much better, right?
- 31:44Yeah.
- 31:44There are some things that have been that it can do to optimize.
- 31:47For example, there's a list of all the built-ins and it knows what return types the built-ins
- 31:53have.
- 31:53So for sure, like it knows if you run list as a built-in function, then it will return a list.
- 32:00And I have even put in a check if somebody's overridden the list built-in, which is possible
- 32:08and had to test that as well, which is interesting.
- 32:11But yeah, it does make a whole bunch of assumptions like that, which is generic and works in most code.
- 32:17And for example, if you're accessing the fourth item in a list, so you've got a list called
- 32:24names.
- 32:25And in square brackets, you put names, square bracket, the number three, then you three is
- 32:31a constant.
- 32:32So it can't change.
- 32:33It's compiled into the function.
- 32:34If the code knows for sure that names is a list, then instead of calling a C API to see what it is and get the
- 32:43index, et cetera, et cetera, et cetera.
- 32:44The JIT compiler can go, oh, I already know this is a list.
- 32:49I know the index you want is the fourth number.
- 32:51So instead of calling all the stuff, let's just calculate the memory address of the fourth item
- 32:57in the list.
- 32:58And then put in a little check to make sure that there are four items in that list.
- 33:02And then, yeah, just compile that into the function.
- 33:05And it's immediately significantly quicker.
- 33:08Go to where the data is stored in the list.
- 33:10Go over by the size of four pointers.
- 33:13So eight times four or something like that.
- 33:15And just read it right there.
- 33:16Something like that.
- 33:17Yeah, exactly.
- 33:17I mean, for sure that that's what it is, right?
- 33:21It sounds dangerous, isn't it?
- 33:23Yeah, exactly.
- 33:24This is some of the security things, right?
- 33:26Go over some part in memory and read it and then do something like that.
- 33:30Sounds like buffer overflow when done wrong.
- 33:32So I can see why you'd be nervous.
- 33:34Yeah, exactly.
- 33:35But that's how compilers work.
- 33:37They you're dealing with memory addresses, essentially, and low level instructions.
- 33:42So yeah.
- 33:43Something we thankfully don't have to do a ton of in Python.
- 33:45But like in CPython, you're in C, right?
- 33:48That's a C thing.
- 33:49Yeah, definitely.
- 33:49And when you're working with duples, yeah, you do that as well.
- 33:52So you work out the address of the nth element and then just use that address and increment
- 33:58the reference counter.
- 34:00Yeah.
- 34:00Also, don't forget that or memory management breaks.
- 34:03This portion of Talk Python To Me is sponsored by Linode.
- 34:10Cut your cloud bills in half with Linode's Linux virtual machines.
- 34:14Develop, deploy, and scale your modern applications faster and easier.
- 34:18Whether you're developing a personal project or managing larger workloads, you deserve simple,
- 34:23affordable, and accessible cloud computing solutions.
- 34:25Get started on Linode today with $100 in free credit for listeners of Talk Python.
- 34:31You can find all the details over at talkpython.fm/linode.
- 34:35Linode has data centers around the world with the same simple and consistent pricing,
- 34:40regardless of location.
- 34:42Choose the data center that's nearest to you.
- 34:44You also receive 24/7/365 human support with no tiers or handoffs, regardless of your plan size.
- 34:52Imagine that real human support for everyone.
- 34:55You can choose shared or dedicated compute instances, or you can use your $100 in credit on S3 compatible
- 35:01object storage, managed Kubernetes clusters, and more.
- 35:05If it runs on Linux, it runs on Linode.
- 35:08If it runs on Linux, you can find the link right in your podcast player show notes.
- 35:15Thank you to Linode for supporting Talk Python.
- 35:18Where are you with this?
- 35:22You said it's going to go to 1.0, which sounds like I could install this and I could run it and
- 35:27it would do its magic, right?
- 35:28It's going to 1.0.
- 35:30Works only on Python 3.10.
- 35:32That's one big thing.
- 35:33I've upgraded it from 3.9 to 3.10.
- 35:36When 3.10 was released, actually, and I won't be backporting it.
- 35:40It's just so much has changed in Python and the APIs.
- 35:45You can pip install it on Python 3.10.
- 35:47You need to have .NET 6 installed when that is released.
- 35:51Or you can install release candidate 2, which is already out.
- 35:55Yeah, you can enable it.
- 35:57Yeah, it sounds like it's pretty close to done, right?
- 35:59I don't know when it's actually, but they've got their .NET conference in, what is that?
- 36:03Six days?
- 36:04Yeah.
- 36:04Surely.
- 36:05Yeah, they say it launches then.
- 36:06It's already online.
- 36:07By the time this episode out, it's very likely very close to just out.
- 36:11So, okay, that's a pretty easy thing.
- 36:13Can I brew install .NET?
- 36:15Do you know?
- 36:15I've not tried.
- 36:16I don't know.
- 36:17That's a good question.
- 36:17Yeah.
- 36:18There is an installer for Mac.
- 36:19Yeah.
- 36:19Pigeon also works on ARM 64, which is worth noting.
- 36:23And it's a very complicated detail of Jet Comparters.
- 36:26But yeah, ARM support was no small feat, but it's something that people just expected to be there.
- 36:31Yeah, sure.
- 36:32Well, I mean, there's obviously the M1s, right?
- 36:35Everyone with an M1 would like, who wants to do this would really like it to work on ARM.
- 36:40But there's also Raspberry Pis and other places that Python shows up.
- 36:44I don't know, helicopters on Mars.
- 36:46I don't know if that's ARM or not, probably.
- 36:47Yeah.
- 36:48So I've tested Linux ARM 64, which will be the Raspberry Pis and other.
- 36:53And also Mac ARM 64.
- 36:55I have not tested Windows ARM 64 because there is no Python for ARM 64 on Windows.
- 37:03Interesting.
- 37:03Okay.
- 37:04Steve Dower has released a preview package of the libraries, but not a standalone executable.
- 37:12But it may come out in the future.
- 37:13We're going off on a bit of a tangent, but...
- 37:16No, but that whole story with Windows on ARM is...
- 37:18I would love to see it better handled.
- 37:21But it's like you can't even buy it, right?
- 37:24Is it supported?
- 37:25It's provided OEMs, but kind of, sort of.
- 37:28I don't know.
- 37:28It's in a weird state, right?
- 37:30It's not normal Windows.
- 37:31It's not super supported.
- 37:33Yeah.
- 37:33I think...
- 37:34Who knows?
- 37:34I can't speak...
- 37:35I do work for Microsoft, so I'm definitely not going to give my opinion.
- 37:38Yeah.
- 37:38I'm not asking for your...
- 37:40This is more of me just making a proclamation.
- 37:42I have Windows 11 running on my Mac Mini M1, and it is running the ARM.
- 37:47But to get it, I had to go join the Insiders program and then install it.
- 37:52And it's permanently got this, like, watermark that it's a tainted version, but you can try
- 37:57to use it.
- 37:58And, you know, it works fine, but it's kind of sluggish and whatnot.
- 38:01So, anyway.
- 38:02Hopefully, that comes along better.
- 38:04Yeah.
- 38:04So, it sounds like it's supported on the various things.
- 38:07Yeah.
- 38:07I have .NET 6 installed and Python 3.10 installed.
- 38:11Neither of those have to be messed with, right?
- 38:14You've got the PEP for Python, and you've got just the JIT.
- 38:17Vanilla installations, yeah.
- 38:19Yeah.
- 38:19That's beautiful.
- 38:19And so, give us a little walkthrough on, like, how we might use this.
- 38:23What do I have to do to change my code to get these compilation steps?
- 38:27Wherever your code starts running, you need to import Pigeon and then call the enable function
- 38:32on Pigeon.
- 38:33Okay.
- 38:33There's also a config function, which configures different settings in terms of how Pigeon
- 38:38runs.
- 38:39Like that threshold, for example, like how many times before you compile.
- 38:43Yeah.
- 38:43The hot code threshold optimization level, which is a level between zero and two, which is
- 38:49like how aggressive the optimizer is.
- 38:51And you can also enable or disable the profiler.
- 38:54Yeah.
- 38:54I remember in C, way back when I was doing C for projects, there were these different optimization
- 39:01levels.
- 39:02Yeah.
- 39:02And it was like, well, you can go to one or two and it'll probably still work.
- 39:06If you go too far, it'll just crash.
- 39:08It's like, what is going on?
- 39:10Like, I don't understand.
- 39:11But okay, we'll just, we'll dial it back until it's stable.
- 39:14And that's as fast as we can make it go.
- 39:16Yeah.
- 39:17This is the same.
- 39:18This is my recommendation is go as hard as you can without it catching fire.
- 39:22Take a step back.
- 39:23Go with that.
- 39:24The start, maybe start at zero.
- 39:26I know it defaults to one.
- 39:28Yeah.
- 39:28Yeah.
- 39:28So yeah, don't turn out to 11, but yeah.
- 39:31And then the profiler is on by default, which I may disable in the future because the profiler
- 39:37probably causes the most issues where you've got a function, which ran with integers a thousand
- 39:44times.
- 39:45And then all of a sudden somebody gave it some floating point numbers.
- 39:48It won't crash.
- 39:49It will just, it will either fall back to default path or it will raise an exception
- 39:53to say that it got some values, which it didn't expect.
- 39:55And if you do see that, it's called a, it'll tell you in the error message and it will suggest
- 40:00that you turn the profiler off and then rerun the code.
- 40:03You know, for me, I feel like that would suggest to me that maybe I should go check my code.
- 40:07Yeah.
- 40:08Not always, but often if I got something like I'm trying to take these things and add them
- 40:12and get what I think is the result.
- 40:14And I'm trying to do math, not string concatenation.
- 40:17And I get a string, chances are that's actually a mistake, not something that I wanted to take
- 40:23account for.
- 40:23It could be, but probably not.
- 40:24Yeah.
- 40:25I actually saw a useful example of this yesterday on, on Twitter.
- 40:28Somebody shared adding two floating point numbers in Python, A and B, A plus B is not the
- 40:34same as B plus A.
- 40:35They actually give different results, which is crazy.
- 40:38But yeah, when you work with floating point numbers and, and integers and you, you don't
- 40:43mean to, but you end up with different types, you will get some weird results anyway.
- 40:47Interesting.
- 40:47Yeah.
- 40:48Yeah.
- 40:48Yeah.
- 40:48So yeah, in terms of whether this will work, I've compiled some pretty big libraries and
- 40:53they've worked fine.
- 40:54Pandas, Flask, Django, chucked a lot of the CPython's test suite.
- 40:59Yeah.
- 40:59This as well.
- 41:00So yeah, it will run about, I guess to about 50,000 tests or something.
- 41:05I think quite happily.
- 41:06That's really awesome.
- 41:06A lot of CPython tests, testing specific internal things in CPython.
- 41:12So some of them do fail, but it's not anything that Pigeon's done.
- 41:15And pytest works as well.
- 41:17So yeah, there's a lot of big libraries.
- 41:20NumPy works fine.
- 41:22I have this test for NumPy, test for Pandas, test for Flask, Django, all the stuff that I'd
- 41:27expect people to try is in there.
- 41:29If you're working with a lot of C extension modules, they also do work.
- 41:32Cython extensions work.
- 41:34So in terms of like compatibility, that was one of the main things I wanted to focus on
- 41:39was instead of going super aggressive with the optimizations, I just want to make sure
- 41:42this works with existing code because there are lots of other projects which.
- 41:47Right.
- 41:47We have PyPy already, P-Y-P-Y, which is also a JIT compiler.
- 41:52And it works in not with the .NET backing the JIT, but some of like the hot functions getting
- 41:58compiled versus just running in Python.
- 42:00That kind of stuff is pretty similar now, but they made the big trade-off like we're going
- 42:04to just go all in on compiling and we're going to not necessarily integrate with the C APIs
- 42:08in the same way, which means breaking with some of these things like NumPy or Pandas that
- 42:13people sometimes care about.
- 42:14Yeah.
- 42:14And they also have to play catch up on the language features.
- 42:17So if there's new features in 3.9, 3.10 in the language, like new operators or whatever,
- 42:24then PyPy has to then go and implement that, which is hard.
- 42:27But Pidgin is, you load it into CPython.
- 42:30So like in terms of language, it would be exactly the same.
- 42:33Right.
- 42:33Often a lot of those language features are just syntactic sugar over existing things,
- 42:38right?
- 42:39Yeah, exactly.
- 42:39And then if there's anything which is not compatible, like I mentioned, async and await, then it will
- 42:44default back to CPython.
- 42:45And that transition is seamless.
- 42:47And you wouldn't, you won't notice it will just, it will just run the code regardless.
- 42:51Awesome.
- 42:51So it looks like, I'll say it works for the most part.
- 42:55I haven't totally tried it, but it sounds like it works quite extensively.
- 42:58The way you use it is you pip install Pidgin and then just import Pidgin, Pidgin.enable
- 43:02is option one.
- 43:04And then that's it, right?
- 43:05There's nothing else that you have to do.
- 43:06Nothing else you have to do.
- 43:07You just run the Python code and it all just automatically spots stuff that it should compile
- 43:13and compile it for you.
- 43:14Fantastic.
- 43:14And then another option I see on the page here is I can say Pidgin space some Python
- 43:19file and not necessarily modify the file, but tell it to execute.
- 43:23What does it do?
- 43:24Import Pidgin, Pidgin.enable, eval, something like that.
- 43:30Yeah, basically it's a very small script.
- 43:34So yeah, Pidgin is a standalone command that you can run instead of, so instead of running
- 43:38Python, you run Pidgin against a script or a module and all the arguments should work as
- 43:44normal.
- 43:45Awesome.
- 43:45You also have the dash M for built and stuff, right?
- 43:48Yeah.
- 43:48So if you want to run a script, then you'd run Pidgin and then the name of the script.
- 43:52If you want to run a module like pytest, for example, then you would do Pidgin dash pytest
- 43:57and it would run pytest with the JIT enabled.
- 44:01Yeah.
- 44:01Fantastic.
- 44:02Or Flask or something like that, right?
- 44:04Yeah, exactly.
- 44:04Yeah.
- 44:04Yeah.
- 44:05So I guess the dash M would work with external libraries, right?
- 44:07Long as like Python can see them.
- 44:09Yeah.
- 44:10And I've shipped a whiskey extension as well so that you can use it in WSGI apps.
- 44:16I think that that's an interesting use case, actually.
- 44:20So when I run my regular Python code, it just loads up and runs.
- 44:24But when I run Flask or FastAPI or Django or Pyramid or whatever, there's all sorts of
- 44:30layers of indirection or layers of not directly running it, right?
- 44:35In production, you would say, hey, I want uWSGI or Gunicorn to run this.
- 44:39Like for FastAPI, it would be, I want Gunicorn to run this, but with uvicorn workers and run
- 44:44five of them and like, boom, boom, boom.
- 44:46Now you've described like this chain of events, right?
- 44:50Yeah.
- 44:50But it sounds like there's, what, middleware to make this work still?
- 44:55Yeah.
- 44:55It's a whiskey middleware that is for Pidgin, which will do the enabling and disabling.
- 45:01Fantastic.
- 45:02So that sounds like it works for any whiskey app, Flash, Django, Pyramid, et cetera.
- 45:06What about ASGI apps?
- 45:08Well, due to the lack of async and await support, then no.
- 45:12It doesn't really make much sense, right?
- 45:13Because like the big thing that it does is like not the thing that's supported, right?
- 45:18Yeah.
- 45:18I mean, if it's an async function, then it will just give it back to CPython.
- 45:22I'm sure there's a lot of synchronous things happening in those various places, right?
- 45:28Maybe the view method itself is async, but it might call a whole bunch of, you know,
- 45:32give me the headers and the cookies synchronously.
- 45:34Who knows?
- 45:35Yeah, exactly.
- 45:35It also depends on the nature of the program as to whether Pidgin's actually going to make
- 45:40a difference to their performance.
- 45:42Yeah.
- 45:43So that's kind of where I'm up to at the moment is different benchmarks and running Pidgin
- 45:50against some standard benchmarks.
- 45:52I shared the N-body execution time at my PyCon talk, and that was 33% faster.
- 45:58It's now 65% faster.
- 46:01So I've doubled that.
- 46:02Oh, nice.
- 46:02Gain.
- 46:03So, however, most people aren't calculating the position of planets.
- 46:08But the few who are, they'll be super thrilled.
- 46:12Yeah.
- 46:13For the few people who are and are doing it in Python, the system doing it in Python.
- 46:16Yeah.
- 46:17Then they'll be delighted.
- 46:18So there are, so code, which is doing a lot of math and is in pure Python would be faster
- 46:24up to 20% fast, 20 times, not 20%, 20 times faster.
- 46:30I've got some micro benchmarks that do like simple calculus and stuff like that.
- 46:35And they're 20 times faster with floating point numbers.
- 46:39And for, I'll say, small integers, because an integer in Python, an int in Python is a
- 46:46called a...
- 46:47It's an unbounded thing.
- 46:48It's bounded by your memory, right?
- 46:50Yeah.
- 46:50It's actually a list of digits.
- 46:51It's not...
- 46:51Yeah.
- 46:52So it can have like an almost infinitely large number inside it.
- 46:56Whereas CPUs work with 32-bit or 64-bit numbers.
- 47:00And the other languages, instead of keep growing, they just go like, we broke.
- 47:04So instead of going one more, it goes like negative 2 billion.
- 47:07Yeah.
- 47:08Yeah.
- 47:09You get funny overflows and stuff.
- 47:11Yeah.
- 47:11So one of the challenges I've had with Pidgin is trying to optimize integers, but trying to
- 47:18understand where it potentially could be a very big number and where the number is like
- 47:23five.
- 47:24What's five times five?
- 47:25You don't need to allocate half a meg of memory to do five times five.
- 47:30Yeah.
- 47:31Yeah.
- 47:31Yeah.
- 47:32So that's one of the challenges.
- 47:33So if you're working with integers and you're working with floating point numbers and you're
- 47:37doing a lot of math and Pidgin will make a dramatic difference.
- 47:39There's also a feature called the graph, which will create .graphviz files for the functions
- 47:48that it's compiled.
- 47:49And you can see this on the website.
- 47:51So if you go to live.trypidgin.com.
- 47:53You've got this interactive live website, right?
- 47:55Yeah.
- 47:56So I've kind of made a sort of live demo site where you can type Python code in and click
- 48:01compile and then it will show you.
- 48:04Oh, don't change it, Michael.
- 48:05You broke it.
- 48:06It's going to be fine.
- 48:08And then do you compile?
- 48:10It's going to be fine.
- 48:11I got faith in you.
- 48:11Now I can delete it.
- 48:13It catches fire.
- 48:13Okay.
- 48:14That's the assembly that it has compiled that Python code into.
- 48:18Okay.
- 48:18And a fun thing I actually added was there's a comment in assembly, which says which byte
- 48:23code this is for, which is fun.
- 48:25If you scroll down on the page, you see this graph.
- 48:28I got to do my screen.
- 48:29Press the IL and then keep going down.
- 48:31Okay.
- 48:32There we go.
- 48:33Here we go.
- 48:33I don't have a big enough screen there.
- 48:35Here we go.
- 48:36Okay.
- 48:37So this instruction graph gets generated if you enable graphing.
- 48:42It's on the documentation.
- 48:44But when you enable graphing, it will show you all the Python byte codes.
- 48:48And then what values are being sent between those byte codes.
- 48:51So this is basically the output of the profiler.
- 48:54It can see here that you've got A and B.
- 48:57B was a float.
- 48:58A is an integer.
- 49:00And then it's doing a multiplication operation.
- 49:03And it knows that if you multiply a float by an integer, then the output is a float.
- 49:06So it carries that value through the graph.
- 49:09PyPyde actually does things quite similar to this.
- 49:11And then once the profiler has run, it will look at the graph and then make some decisions
- 49:18about which values don't need to be Python objects.
- 49:22So for example, A times B.
- 49:24Right.
- 49:25There's these intermediate binaries here and stuff, right?
- 49:29This in-place add, all those, yeah?
- 49:30So yeah, exactly.
- 49:31So all of those values do not need to be Python objects.
- 49:35So what it will do on the next pass is it will recompile that.
- 49:39And then it will, what's called, unbox them.
- 49:41So it basically just carries them in CPU registers as integers and floats.
- 49:46And then instead of running the C function to add two numbers together, it will just emit the assembly instruction to add two numbers on the register.
- 49:54Yeah, that's fantastic.
- 49:55That's what you're talking about where you don't have to drop back into allocating Python numbers if you know for sure that no one's going to look at it.
- 50:04It's just an intermediate value.
- 50:06And this is where it gets tricky with integers, right?
- 50:08Because A and B might be small, but A to the power of B might be larger.
- 50:12Exactly.
- 50:13And then it goes one step beyond as well if you have code that uses fast values.
- 50:19It's tricky because when you do eval on the website, it will never have used fast locals.
- 50:24But if you do have a function that has fast locals, if it detects that that local is only ever used in places where it can be unboxed,
- 50:33then it won't actually store the variable as a Python object either.
- 50:38It will store it as a native stack value.
- 50:41So that's something it even does will, like if you have a variable called A and you assign it to the number two,
- 50:46then it will actually just reserve an area in memory just to store that stack value.
- 50:52And it will be an offset.
- 50:54Which is way more efficient.
- 50:55Enormous, like thousands of times more efficient.
- 50:58And when you refer to that variable in your function, it will basically just access that point in memory to get the actual value.
- 51:06Yeah.
- 51:07Yeah.
- 51:07Awesome.
- 51:08This is really neat.
- 51:09One thing that stands out to me here is I wrote name equals Anthony plus Shaw as two strings.
- 51:14And that was, you're like, don't do it.
- 51:16And yet what I see in the graph here is that it loads the string Anthony Shaw.
- 51:22So did Python look at that and then decide that that's actually, those are two constants.
- 51:28So we'll just make it one constant or was that .NET or what happened there?
- 51:32Yeah.
- 51:32That's constant folding is a feature of Python.
- 51:35Yeah.
- 51:35That's what I thought.
- 51:36If you do, yeah, two strings and a plus, it will actually compile those into one string.
- 51:41You'd never, you'd never see it.
- 51:43Oh, interesting.
- 51:43Because they're statics, right?
- 51:45Like it knows both of them.
- 51:46Yeah.
- 51:47Okay.
- 51:47Very interesting.
- 51:48So it sounds like for numerical stuff, this is quite a bit faster.
- 51:52Did you do any tests on the web frameworks?
- 51:54I mean, it's kind of appealing to say, what if I could get Flask to kind of run natively?
- 51:58Yeah, I have.
- 51:59Because when you look at what, when you think about I'm writing this code to make this website go, most of what you're doing is you're doing like a little tiny bit of code on top of a big framework that's doing most of the heavy lifting, right?
- 52:11So if you could make Flask do that magic faster or Django or whatever.
- 52:16Yeah.
- 52:18So the areas where Python is faster as numerical work, similar to PyPy, PyPy is a lot faster with numerical work.
- 52:25Yeah.
- 52:25It can make clear and simple assumptions and optimize based on the CPU.
- 52:30So that's brilliant.
- 52:31Areas where it's, it's sometimes it's not faster or sometimes even slower is code, which is just uses a lot of classes and very small functions.
- 52:41Partly just because of the way the PEP is designed, it will JIT compile functions.
- 52:47And if your functions are just working with custom classes and you're passing things around, then trying to decide what type things are and then how it can optimize types.
- 52:57Yeah.
- 52:57If everything is a Python, custom Python object, custom Python class, there's very little it can actually do to optimize.
- 53:04Yeah.
- 53:05And when you were talking about the specializations earlier, it's one thing to say, well, I'm passing a customer and an order object, but then they have fields themselves, each of which have potential types, right?
- 53:15Like it's this, this object graph, this closure of all the object graphs.
- 53:20And you got to look at all those types you might touch, right?
- 53:22Yeah.
- 53:23And then you've also got to check that fields exist.
- 53:25It's been set.
- 53:26It's not none.
- 53:27I mean, like if you Django.
- 53:28By the time you're done testing them all, you might as well just run it.
- 53:31By the time you've done all of that, you've basically just written what CPython would have done anyway.
- 53:36Yeah.
- 53:36But the difference is that if you JIT compile it, you've got to emit all those instructions.
- 53:40And the compiled function, the JIT compiled function ends up being bigger because, you know, if it's compiled in C, it just has one function that does that, that's shared by all libraries.
- 53:51Whereas in the JIT, you have to make it so that it's their standalone functions.
- 53:56So that's one downside is that if you're working with stuff which is similar to Django and Flask, I guess like lots of classes, lots of variables, which are all custom types, probably not going to see a performance improvement or potentially it could even be slower.
- 54:10Will it be transitive?
- 54:11If I write code that runs in Flask, let's just pick one of them.
- 54:14And I run Flask with Pigeon.
- 54:17Will that then make all my code that Flask is executing also run in Pigeon?
- 54:22Yeah.
- 54:23So maybe if I was doing like highly computational stuff in my Flask app, having to do that might be worthwhile.
- 54:29Yeah, definitely.
- 54:29And in that case, you can just enable Pigeon before those functions or you can set the threshold to be higher.
- 54:36That's probably what makes more sense, I think.
- 54:38Yeah.
- 54:38The other area is strings.
- 54:40So if you're doing a lot of work with strings, I haven't done any work on optimizing strings.
- 54:44And I'm not particularly sure what you would optimize either because they're so complicated.
- 54:50Because you're dealing all with Unicode, different encodings, different bit lengths.
- 54:56Yeah, I don't even know how you would improve upon CPython's string implementation, to be honest.
- 55:03Yeah, there's a lot of nuances to strings in all the languages about it, especially in Python, because you don't have to think about it, right?
- 55:09The fact that you don't know how complicated Unicode is and, you know, word alignment and null characters and so on and so on.
- 55:19Yeah, if you want a glimpse of how complicated it is, look at the Unicode object source file in CPython.
- 55:25Is it big?
- 55:26It's an absolute monster.
- 55:27I bet it is.
- 55:29It's probably more complicated than C of L, actually.
- 55:31It's...
- 55:32Oh my goodness.
- 55:33Yeah.
- 55:33All of that for emojis.
- 55:34For emojis.
- 55:35Okay, I understand there's other languages.
- 55:37No, interesting.
- 55:39So one thing I wanted to ask you about here, I was hunting around on the screen for it, is it's cool that you can compile these things down and run them as native machine instructions,
- 55:48instead of piping them through C of L.C as single line operations.
- 55:52That's great.
- 55:53But when I think of the stuff that compilers can do and JIT compilers, it's a lot about the optimizations.
- 56:00It's like, I saw this function and this function.
- 56:03Actually, we're going to inline that one.
- 56:04And this one, we're going to rewrite this as some other thing that's going to be more efficient because we're seeing that.
- 56:11And so you do have some optimizations, right?
- 56:13Like that's part of the magic.
- 56:14Yeah.
- 56:15So I've kind of documented them as best I can on the Pigeon documentation.
- 56:19There's a section called built-in optimizations.
- 56:21And I've given them all numbers.
- 56:23And if it uses that optimization, it will flag the function to say, oh, I'd use this optimization on this function.
- 56:30And then in the documentation, I'll explain what's the background.
- 56:33What was the idea?
- 56:34What difference does it make?
- 56:36You want to give some examples from some of these, like the is one, for example?
- 56:40Yeah.
- 56:40So if you're using the is operator in Python, so if something is false, or you actually probably use not something.
- 56:49Is none or something like that.
- 56:50Yeah, is none.
- 56:51Then it won't run the pyis function.
- 56:54It won't run the C API to do an is comparison.
- 56:57It will just look at the address of both objects and see if they're the same.
- 57:01Because is actually asking, are these objects the same, not are they equivalent, right?
- 57:06So the same in CPython is the pointer addresses are equal.
- 57:10Yeah, exactly.
- 57:11It will just compile that down to a simple pointer comparison.
- 57:14That's actually one of the first ones I wrote, and it was good to learn.
- 57:18Also, when it's doing comparisons for small numbers.
- 57:22So Python inter, it kind of immortalizes numbers between, I can't remember the range.
- 57:28Negative five and 256?
- 57:29Yeah, that's it.
- 57:30Because they use so much that...
- 57:32Maybe 255, but basically.
- 57:34It's around that many.
- 57:35It immortalizes them, and then that keeps them as constant objects so that they're just reused.
- 57:40So if you create a new integer with the number one, it will just reuse the same number one that it used before.
- 57:45Right.
- 57:45Because they're not created on the stack.
- 57:47They're like complicated things on the heap.
- 57:49So yeah.
- 57:50Exactly.
- 57:50So if you do, if something equals equals 25, Pidgin will go, oh, well, I know 25 is an intern number.
- 57:58So I'm actually just going to do a pointer comparison instead of a value comparison if the left-hand side is a number.
- 58:03So that they have to sort of like little things like this, which make small differences, but when you add up...
- 58:09They add up, right?
- 58:09Yeah.
- 58:10So I felt like, I don't know where you are now from where you were when you spoke at PyCon,
- 58:14but I feel like this is an area that people could come contribute to.
- 58:18This is an area for growth that doesn't require a lot of changes.
- 58:22It could be super focused.
- 58:23But if you see this situation, you know, here's one more way to make it faster.
- 58:27Absolutely.
- 58:28So yeah, this is one area where I was hoping that the research that I was doing whilst writing Pidgin could contribute to other projects.
- 58:36And I'm going to, I've been talking to Carl Friedrich-Osch as well, who works on PyPy.
- 58:41And we're going to do some pair programming at some point to see kind of like how different projects work and stuff like that.
- 58:50But kind of hopefully these optimizations can be learned from and then used when CPython gets to implementing its JIT.
- 58:58Yeah.
- 58:58Surely the .NET compiler has all sorts of optimizations in it.
- 59:03Are you already taking advantage of those to some degree?
- 59:06Yeah, some of them.
- 59:07Just by nature of letting it run, basically.
- 59:09Yeah, some of those optimize it.
- 59:11It does a lot of them already.
- 59:13And I've been working with the compiler team on the .NET project as well.
- 59:18Pidgin is one of the only projects to use the compiler directly.
- 59:22Even though it can be used in that way, it's, it wasn't, it was really, I think it was designed to be run directly, but it's not like advertised as an off the shelf JIT.
- 59:32So yeah, there aren't many projects that are using it in that way.
- 59:36And I do work with the compiler team, like specific test cases and stuff as well.
- 59:40You do have that advantage of being on the inside at Microsoft, even if you're like half a world away, you still can get direct access remotely, which is like being down the street these days.
- 59:51Yeah, I've done everything.
- 59:52It's all been via GitHub though.
- 59:53So I think as far as they're concerned, I'm just another name on GitHub, but like I don't, it doesn't.
- 59:59They might not even know, right?
- 1:00:00I probably didn't even know.
- 1:00:02Yeah.
- 1:00:02That I work.
- 1:00:03Yeah.
- 1:00:04Let's see.
- 1:00:06What else?
- 1:00:07I think we pretty much have covered it given the time that we got.
- 1:00:10I mean, another area that's interesting is how does it compare to the other things that have been done before it or going along a parallel?
- 1:00:18And, you know, you do have a whole section on the read me on the GitHub page.
- 1:00:22Like how does this compare to X, Y, Z, PyPy, Piston, Numba, Iron Python, and so on.
- 1:00:29Do you want to maybe just have a quick statement about that?
- 1:00:31Yeah, I think it's really hard to compare them.
- 1:00:33So probably the most obvious ones to compare it with would be Cite and Numba and PyPy.
- 1:00:39So PyPy is a Python interpreter that has a JIT.
- 1:00:44So it interprets, compiles, and runs Python code written in Python.
- 1:00:48PyPy has been around.
- 1:00:50Right.
- 1:00:50It's like a fork of Python that was rewritten to behave differently rather than PEP523, right?
- 1:00:55Yeah, exactly.
- 1:00:56So it's not Cite Python is written in C.
- 1:00:58PyPy is written in Python and probably significantly faster in many cases.
- 1:01:05It's a very mature project.
- 1:01:07But obviously that there's limitations around C APIs and some things don't work in PyPy.
- 1:01:14Numba is a JIT.
- 1:01:16It's a JIT specific for NumPy.
- 1:01:19If you're using NumPy, then if you use Numba, Numba can JIT compile NumPy data arrays and stuff like that.
- 1:01:27That's actually a very specific use case.
- 1:01:29Right.
- 1:01:30That's great.
- 1:01:30But if you're not doing NumPy, then not too much.
- 1:01:33In any other use case, it would make very little, if any, difference at all.
- 1:01:37And then Cython is not a JIT.
- 1:01:40It's an AOT compiler.
- 1:01:42And it's a way of annotating Python code with concrete types.
- 1:01:46And then it compiles them into C.
- 1:01:49Concrete compiles them into C extensions.
- 1:01:50Yeah.
- 1:01:51It's a little bit like what you're talking about, trying to understand what are these types and then can we create a specialization.
- 1:01:56But it's the developer who just says, no, these are integers.
- 1:01:59This is the list.
- 1:02:00For sure.
- 1:02:01Go with it.
- 1:02:02Yeah.
- 1:02:02That's the point where you actually specify the length of the integer as well.
- 1:02:05So in Cython, you would say this is a 64-bit integer so that it knows that it can be converted into a 64-bit integer in C.
- 1:02:14Pidgin is probably the closest to Cython.
- 1:02:17But obviously with Cython, you have to compile it to a C extension ahead of time.
- 1:02:21Whereas with Pidgin, you just import it into Python and just turn it on and it just runs and compiles live.
- 1:02:27And it will, yeah, you don't have to have different compiled versions of your app or your library, not necessarily because of this anyway, for different platforms, right?
- 1:02:35And you don't have to annotate the code in this sort of special syntax either.
- 1:02:39Yeah.
- 1:02:40Well, let's close this out with a question on that.
- 1:02:43So in Python, we've been able to say optionally that this thing is an integer, you know, x colon int, or it's an optional integer or it's a customer or whatever the heck it is.
- 1:02:54We've had these type annotations and traditionally they've meant nothing, right?
- 1:02:58Except for if you run tools against them.
- 1:03:00On the other hand, we've had things come along like Pidantic, like FastAPI that look at that and go, you know what?
- 1:03:06I'm going to do something with that because I got a string because this is the web and that's all I usually get.
- 1:03:10I'm going to make that into an int because you said it's an int.
- 1:03:13Is there a scenario where type annotations play into this to enhance it somehow?
- 1:03:18I'm against that idea, potentially.
- 1:03:21I mean, that's how Cython works.
- 1:03:23Yeah.
- 1:03:24I think, and with type annotations as well, having a type checker is great until the types are wrong and it's not a fault of your own.
- 1:03:33And having work on like strongly typed languages, like C#, C# is brilliant, except when you need to do things like reflection.
- 1:03:42So let's say you're working with JSON data or YAML, for example.
- 1:03:47And working with JSON and YAML in C# is incredibly hard.
- 1:03:53Because you're like, oh, I've had to do parsing YAML files in Java.
- 1:03:59It's incredibly difficult because you're like, oh, well, this could be a list of strings or it could be a dictionary where the key is a string, but sometimes it's a number.
- 1:04:12Which is like YAML is like that sometimes.
- 1:04:14And JSON is like that.
- 1:04:15It's completely free.
- 1:04:16So when you're working with dynamic content using strongly typed languages is extremely difficult.
- 1:04:21It just gets in the way and just makes your life harder.
- 1:04:23And the compiler just complains and just won't let you parse because it's saying, oh, well, that's not compliant with my view on the world.
- 1:04:31With Python, I think it's cool to say, okay, if I just tag this as an integer, then it should be able to optimize it for integers.
- 1:04:38And I think that's what Mark was suggesting.
- 1:04:39If it stops there, that's fine.
- 1:04:41I think if it goes beyond that, then that's where things get very, very complicated.
- 1:04:44And it just becomes a thing that's in the way being noisy and it slows you down.
- 1:04:50That's where I have a strong disagreement with it is that we use Python because it's fast to develop in.
- 1:04:56And it's fast to develop in because, you know, if you know what you're trying to get it to do, then the compiler doesn't really give you any grief.
- 1:05:03If it's syntactically, it's okay.
- 1:05:04I'll just try and run it.
- 1:05:05Yeah.
- 1:05:06And I think the thing that's most similar to this is TypeScript.
- 1:05:10And my experiences with TypeScript have been often met with frustration.
- 1:05:14I think it's really cool that you can write.
- 1:05:17The language specification is really neat, but I want to use this library and that thing and pull them together.
- 1:05:21And if that thing doesn't have the type specified just right, I can't get JavaScript to pop out the other side because the transpiler gives you a compiler error.
- 1:05:30Like, this doesn't work right.
- 1:05:31Well, they know it's going to work right.
- 1:05:32Just let this little part go through.
- 1:05:34I just, I don't want to re...
- 1:05:36I know there's ways to say this is just any and stuff, but still.
- 1:05:39I feel like my experience was bumping up against that stuff, even though it's kind of the same as Python type annotations in a lot of ways.
- 1:05:47Yeah.
- 1:05:47And under the hood, it's still dynamic.
- 1:05:49Yeah.
- 1:05:49Yeah, exactly.
- 1:05:50At runtime, it would still be the same thing, but you won't get to the runtime because you can't get the stuff compiled.
- 1:05:56Yeah.
- 1:05:56Or it does really weird things at runtime that at compile time, it made assumptions that wouldn't happen.
- 1:06:01All right.
- 1:06:01Let me throw one quick thing out there before you pass final judgment on this type thing.
- 1:06:07Because you're right.
- 1:06:08I could write a thing that says my function takes an int and a string, and I could run my pi against my code.
- 1:06:15And sure enough, it only takes ints and strings in these situations.
- 1:06:18But if it's a library, all bets are off.
- 1:06:20There's nothing that says people who use your library are going to run my pi and listen to that or do anything, right?
- 1:06:27They could write in Notepad if they had no self-respect, but that would like you could write whatever you want, right?
- 1:06:32And then you could just feed it on and then you'd have these problems.
- 1:06:35That said, over on the Pydantic world, there is a validator, a decorator called at validate arguments that will make sure at runtime, they really are a string in an int.
- 1:06:47Yes.
- 1:06:48To make you feel any better?
- 1:06:49Probably not, because the transitive closure of objects is too complicated to check and describe.
- 1:06:54The validate arguments is, I think, it's a convenience function.
- 1:06:57It's there because you often have to validate data, user-provided data that's coming in from an interface, like a web interface, or via a file, or an API of some sort.
- 1:07:08So if people are submitting user-provided data, then you want to have to validate the types.
- 1:07:13And that is just a lot of boilerplate code, and it's annoying to write.
- 1:07:17As a convenience function, let's write this thing.
- 1:07:20Right.
- 1:07:20Probably because we're going to immediately try to convert it in the next thing, right?
- 1:07:24Yeah.
- 1:07:24Yeah, exactly.
- 1:07:25So I think it's quite different to using it internally to make changes in terms of how the code is compiled.
- 1:07:34Yeah.
- 1:07:35For numbers, like I said, numbers and strings and base types, I think is cool.
- 1:07:39But for objects, like which fields do you assume exist?
- 1:07:43Yes, exactly.
- 1:07:44And then do they all have to match the types or just the two that you touch?
- 1:07:47Yeah.
- 1:07:48You've got an attribute there.
- 1:07:49Like sometimes it has a getter and a setter.
- 1:07:51Sometimes it's just an attribute.
- 1:07:53Sometimes it's a descriptor that inside the descriptor is the thing you actually want.
- 1:07:58Is that the right type?
- 1:07:59Yeah, you're right.
- 1:07:59It's insane.
- 1:08:00It's just, oh yeah.
- 1:08:01Once you kind of open, I think that once you open custom types, then it just kind of mushrooms
- 1:08:06into this.
- 1:08:07Sure.
- 1:08:07And that's why you see things like Cython and stuff having like little fragments of here's
- 1:08:12some limited code that we're going to use, often fundamental types.
- 1:08:16Yeah.
- 1:08:16Yeah.
- 1:08:16Cool.
- 1:08:16All right, Anthony, this is really awesome.
- 1:08:18I could tell you've done a massive amount of work on it.
- 1:08:21That's more stuff I want to talk to you about, but I think we're out of time, like calling
- 1:08:26into .NET, stuff like that.
- 1:08:27But we'll save that for some other time, huh?
- 1:08:29Yeah.
- 1:08:30Until you have a little more progress.
- 1:08:34Now, you know, there's always the two questions at the end of the show.
- 1:08:37So if you're going to write some code, what editor are you using these days?
- 1:08:41VS Code.
- 1:08:42Right on.
- 1:08:42Yeah.
- 1:08:43And notable IPI library.
- 1:08:45I mean, it could be Pigeon.
- 1:08:47Anything else?
- 1:08:48It's like you come across like, wow, this is awesome.
- 1:08:50Yeah.
- 1:08:50I think I mentioned it before.
- 1:08:51Tortoise, I'm a big fan of at the moment.
- 1:08:53Yeah.
- 1:08:54Tortoise ORM.
- 1:08:54Yeah.
- 1:08:55It's a nice async ORM.
- 1:08:56Yeah.
- 1:08:57And Beanie as well.
- 1:08:59I'm really enjoying playing with Beanie as an ODM.
- 1:09:01Yeah.
- 1:09:02Async ODM on top of Mongo.
- 1:09:04Yep.
- 1:09:04Beanie is very cool.
- 1:09:05I'm actually having Roman Wright on the show talk about Beanie not too far out as well.
- 1:09:10And Beanie is cool because it's basically Pydantic plus async and await on top of MongoDB, which
- 1:09:15is cool.
- 1:09:15Can I have three?
- 1:09:17You can have three.
- 1:09:17I released like a small package called Hathi, which is a SQL attack tool for Postgres, MySQL, and SQL Server.
- 1:09:26I'm looking at your GitHub profile here.
- 1:09:28You've got one of these fancy profiles with the new readme that shows up and all of your stars.
- 1:09:33Look at this.
- 1:09:33Yeah.
- 1:09:34Like I made a custom graphic for everything.
- 1:09:35Yeah, you did.
- 1:09:36That's fantastic.
- 1:09:37Okay.
- 1:09:38What is this one called?
- 1:09:38Hathi.
- 1:09:39H-A-T-H.
- 1:09:41I have too many repositories.
- 1:09:42I need to go up.
- 1:09:43Hathi.
- 1:09:43Got it.
- 1:09:44It is a dictionary attack tool for Postgres, MySQL, and MSSQL, Microsoft SQL Server designed for internal testing, of course.
- 1:09:53Don't be bad.
- 1:09:54Yeah.
- 1:09:55So don't break the law.
- 1:09:56And yeah, I've been using it to test like internal, not internal stuff, but test environments and look at like bad passwords.
- 1:10:05See if like an admin has a login, like password, password one or admin or super user has a login or whatever.
- 1:10:11Yeah.
- 1:10:12It was also a test of like I think an await networking and how fast I could make it.
- 1:10:17It can do up to 120 login attempts a second.
- 1:10:21So yeah, on my machine.
- 1:10:23But if you maybe this is a four core Mac, but yeah, if you had a few more CPUs, you could probably get a bit more than that.
- 1:10:30But yeah, it'll go through a few thousand passwords.
- 1:10:32And there's a password list in there as well of about 10,000 common database passwords.
- 1:10:37Yeah.
- 1:10:37Nice.
- 1:10:38So yeah, just make sure your password is not on the list.
- 1:10:40And if it is, you can raise a pull request to remove it.
- 1:10:43Yeah.
- 1:10:44Yeah.
- 1:10:45You don't want to have your database open.
- 1:10:48Like it doesn't get much worse than I just have read write access to your database.
- 1:10:53But that's what this would test for, right?
- 1:10:55Yeah.
- 1:10:55Yeah.
- 1:10:56So you can scan a cluster or a machine and see if it can predict what the username password is.
- 1:11:01Yeah.
- 1:11:01Cool.
- 1:11:02All right.
- 1:11:02Well, those are three great recommendations.
- 1:11:04It's awesome to have you back on the show.
- 1:11:07And congratulations on the work here.
- 1:11:08You know, final call to action.
- 1:11:10You know, people maybe to try Pigeon.
- 1:11:12You want them to contribute.
- 1:11:13Got other ideas.
- 1:11:14What do you say?
- 1:11:15Yeah.
- 1:11:15Go to trypigeon.com.
- 1:11:17Yeah.
- 1:11:17On trypigeon.com, you'll see at the top, you can try it out live.
- 1:11:21Link to documentation.
- 1:11:22Link to download.
- 1:11:23Yeah.
- 1:11:24I'd love more contributions or discussion, I think, around what optimizations you could have and people using it and checking it out.
- 1:11:31And if you have any issues, you just raise them on GitHub and I'll check them out.
- 1:11:34All right.
- 1:11:34Fantastic.
- 1:11:35Well done.
- 1:11:36I can tell this is a ton of work.
- 1:11:37So you've come really a long ways.
- 1:11:40And congrats on 1.0 when it comes out in a few days.
- 1:11:42Thanks, Michael.
- 1:11:43Yeah.
- 1:11:43You bet.
- 1:11:43See ya.
- 1:11:44See ya.
- 1:11:44See ya.
- 1:11:45This has been another episode of Talk Python To Me.
- 1:11:48Thank you to our sponsors.
- 1:11:50Be sure to check out what they're offering.
- 1:11:51It really helps support the show.
- 1:11:53Choose Shortcut, formerly Clubhouse.io, for tracking all of your project's work.
- 1:11:58Because you shouldn't have to project manage your project management.
- 1:12:01Visit talkpython.fm/shortcut.
- 1:12:04Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
- 1:12:09Develop, deploy, and scale your modern applications faster and easier.
- 1:12:13Visit talkpython.fm/Linode and click the Create Free Account button to get started.
- 1:12:17Do you need a great automatic speech-to-text API?
- 1:12:21Get human-level accuracy in just a few lines of code.
- 1:12:23Visit talkpython.fm/assemblyai.
- 1:12:26Want to level up your Python?
- 1:12:28We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:12:32Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:12:37And best of all, there's not a subscription in sight.
- 1:12:40Check it out for yourself at training.talkpython.fm.
- 1:12:43Be sure to subscribe to the show.
- 1:12:45Open your favorite podcast app and search for Python.
- 1:12:47We should be right at the top.
- 1:12:49You can also find the iTunes feed at /itunes,
- 1:12:52the Google Play feed at /play,
- 1:12:54and the direct RSS feed at /rss on talkpython.fm.
- 1:12:58We're live streaming most of our recordings these days.
- 1:13:02If you want to be part of the show and have your comments featured on the air,
- 1:13:05be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:13:10This is your host, Michael Kennedy.
- 1:13:11Thanks so much for listening.
- 1:13:13I really appreciate it.
- 1:13:14Now get out there and write some Python code.
- 1:13:16Thank you.
- 1:13:16Bye.
- 1:13:17Bye.
- 1:13:17Bye.
- 1:13:17Bye.
- 1:13:17Bye.
- 1:13:17Bye.
- 1:13:17Bye.
- 1:13:17Bye.
- 1:13:18Bye.
- 1:13:18Bye.
- 1:13:18Bye.
- 1:13:19Bye.
- 1:13:19Bye.
- 1:13:19Bye.
- 1:13:20Bye.
- 1:13:21Bye.
- 1:13:21Bye.
- 1:13:21Bye.
- 1:13:21Bye.
- 1:13:21Bye.
- 1:13:21Bye.
- 1:13:21Bye.
- 1:13:22Bye.
- 1:13:23Bye.
- 1:13:23Bye.
- 1:13:23Bye.
- 1:13:23Bye.
- 1:13:24Bye.
- 1:13:24Bye.
- 1:13:26Bye.
- 1:13:28Bye.
- 1:13:30Bye.
- 1:13:32Bye.
- 1:13:34you
- 1:13:34Thank you.
- 1:13:36Thank you.