Hey everyone, Michael here. Just a quick show note before we get started on this episode.
I think we have a great set of topics to cover, but unfortunately, something went crazy with my
computer and just pinned all the cores and basically made the recording of my high quality
version fall apart. And so when you listen to this, there'll be a little bit of static on my
end. And I just want to say, sorry about that. We had some backup audio, but it also got messed up.
So basically this, I've tried to make it as good as possible, but there's a little bit of issue with
the audio. If you can handle it, there's some great news. And if you want to skip this one and just wait
for next week, totally understand as well. All right. Without further ado, let's get to the news.
Thanks. This is Python Bytes, Python news delivered directly to your earbuds. It's Monday, March 13th,
2017. And this is your host, Michael Kennedy here with my co-host, Brian Okken. Hey, Brian,
you ready to share the Python news with the world?
I am very ready. Excited.
Would you say that you're on fire?
I am on fire. Yeah.
Awesome. Yeah. Google's on fire too, right?
Well, yeah. So I'm, I'm actually a little confused about where this is coming from,
but there's a, yeah, our first topic is, was suggested by several listeners. We got it through
email and through Twitter to cover a tool called Python fire from, I, I don't know where it's from.
It's, it's on the Google repo on GitHub. But it, at the bottom, it says it's not a Google product. So
I don't know what that means.
I think it means it might've been created by somebody at Google, but it's not supported in
any way. It's just, Hey, this is a cool thing we made. So we should have it.
Yeah. I downloaded it and gave it a shot. It says, so we haven't even said what it is. It's
command line interface utility and their tag, the, at the top of the repo says Python fire is a
library for automatically generating command line interfaces from absolutely any Python object.
It is pretty cool. Another thing, it says a list of the benefits, a simple way to create a command
line interface in Python, and you can use it for exploring and debugging existing Python code.
And it makes transitioning between bash and Python easier. I actually, so I tried it out,
downloaded it, wrote a couple of little tools and I actually, it was pretty fun. But I don't think
I would use it for a shippable, a shippable Python like command line interface because it's pretty big.
Yeah. And by big, you mean it has some heavyweight dependencies, right?
Yeah. Like it includes all of IPython. That's quite a bit coming with it. I mean, it also includes
six, but that's really not that big of a deal.
Yeah. Six is just like a basically one little module or whatever, but yeah.
IPython, that's, that can be one of those things that's really hard to,
to even install for some people, right? Like you give that to somebody on a Windows machine,
they don't have like a compiler set up, right? That can be quite challenging.
I'll have to see. I'm going to, I'm going to install it on a Windows machine this week to try that out.
Yeah. Cool. But it does look really great. You basically have a class and you just,
for your main, you just call fire and you pass it the class and boom, that thing is, is CLI callable,
right?
Yeah. But you don't, you don't have to use a class. You can also use just,
you can have a set of functions you can put together and, and add those as the interface.
And there can be multiple, multiple entry points as well. Like I tried, I tried throwing in like two or
three functions and then listing those as all things that you can call from the command line.
And, and it actually picks up, it picks up doc strings pretty well to show you. So you
kind of have help built in as well. I'm going to, I'm going to use it for like,
we've got test instruments we try to communicate with and writing, writing to and from the instrument
from Python is really easy from the bash. Not so easy. but I'm going to think,
I think I'm going to use this to try to do that at work.
Okay. Yeah. And it sounds cool. You have to give us a report on your experience.
Cool. So the next thing I want to talk about is Simon, like Simon says, but a cool menu bar
application for macOS. So if you don't care about macOS, maybe you don't care too much about this. But
one of my pet peeves is I think we need more full on native cross platform GUI things. We've had
PI cute and PI side and the QT framework. That's one option that we've had. That's pretty good,
but there's a lot of, a lot of versioning licensing funkiness going on until maybe till the end of this
year, actually, till they come out with PI side two, then maybe, maybe that becomes a really,
really great option. But we have things like PI OBJC, similar stuff for windows, similar stuff for
Linux, where you can basically somebody already has wrapped the truly native OS elements. So with this
thing called PI OBJC, you can basically create using Python what is indistinguishable from a native app,
like the controls literally are the same as if you had done it with Xcode and Objective C or Swift.
That's pretty cool, right? Yeah, it's, I hadn't heard of this. This is neat. Yeah. So the Simon
thing is not like a framework. It's just an app, right? So some guy is like, hey, I really want to
have a little thing I can click on. It'll tell me my, my network usage, my CPU usage, battery, or whatever,
something like this, right? And he did it as one of those little menu bar things, like what runs in the
top right by the clock on macOS. And you click it and it drops down info about your system. If you
look at the code, it's like, it depends on PI OBJC. But beyond that, it's like 150 lines for a full
implementation of that app. That's pretty cool. And so if you're thinking about you need just a little
simple something to run like as a menu bar app or the notification tray on windows or something like
this, you know, this is a really cool option. And I've mostly wanted to pull it out as like, hey,
here's an example. You could probably clone and tweak or just take the ideas of this
and go. So you just, you create an app, you derive from NS application, which comes from PI OBJC.
You implement a few methods and boom, you've got a nice native GUI app.
Okay. I'm going to have to try this one out too. It's neat.
It's neat, right? The final mix would be to use something like PI to app or something where you
bundle it in a distributable way. So it's not like, well, make sure you, you know, pip install this
thing before you can run it, right? Like that's probably not going to fly so well for like end users,
but still pretty excellent.
So is this a PI OBJ, what is that other one?
PI OBJC as objective C, like the Python wrappers for objective C.
Okay. So that's just a Mac only thing, right?
Yes, exactly.
Okay.
But we can do similar stuff in the other frameworks, I believe, right?
Like on the window side, you can use WPF, which is kind of way more heavyweight,
but you can build the Python stuff using Iron Python. And I'm sure there's something with
GDK and Linux as well.
Neat.
Yep. Neat. It's kind of lunchtime. I'm getting hungry. I wish I had some free food. Really,
I'm hungry.
Well, I was just amused. I don't know if these are useful or not, but I was amused by, in
reading Reddit this last week, there were a couple of things that popped up and one of
them was finding, this was actually useful, finding free food with Python. And it's actually
an article talking about using web scraping to, apparently there's a couple of places that
have like food delivery places that sometimes run specials where they're actually deliver
free food to you. And, but you have to be paying attention to have that work. And so somebody
wrote an app with web scraping and Twilio to occasionally check on this and then text him
information about the free specials. And I probably won't do this, but I think it's a nice,
a nice example of showing, combining Twilio with, with web scraping.
It's cool. Do you know what I like about it is it's taking these techie digital API type
things and it's making real stuff happen. Like, yeah, like you're, you're integrating Twilio
and screen scraping and then you have free food. Like how cool is that? Right.
Yeah. But I, so I would, yeah, you definitely real world probably have free food. I think it'd
be cool to run. I was thinking about doing a similar thing like, monitoring. So we have,
uh, build machines and stuff and I wouldn't mind having a something that sat around and
monitored that and then, texted me the results cause I don't know how to do that.
Yeah. That's cool. Definitely some cool Twilio integration there.
And then the, the next, the next article just amused the heck out of me. It's called,
um, notification notification when friends order pizza. so I don't know if this is a great
thing or not for dominoes to do, but there's, apparently a way that you can plug in phone
numbers and find out, whether that phone number has ordered pizza recently. And, and so somebody
wrote a script to put in all of their friends phone numbers and, text them or let them know when
they're one of their friends is ordering pizza. I guess another way to get free food is to mooch
off your friends when they order food. Yeah. That's, I'm not sure how I feel about that. Actually.
That's a little creepy, man. It actually is creepy. I was thinking that like, I was wondering
whether or not I should include that, but it was, it amused me. So the, the, I don't think that really
it ought to be that easy to find out whether or not somebody ordered some pizza. Yeah. Well,
if, if all your friends start showing up every time you have dominoes,
yeah, I was trying some funky stuff, man. They also have a bot. Like you can order pizza just by
like chatting with dominoes, which is also kind of funky. I want. Yeah. But, but like you could order
food for other people then or something. I don't know. It seems, it seems like they're playing with
scary interfaces, but at least they're playing with interfaces. Yeah, exactly. Exactly. Like it's,
it is pretty cool. Okay. So speaking of food, I want to talk about pi,
HTT pi, which is a little utility written in Python that is kind of like w get or curl,
except for that. It's awesome. And the reason it's awesome is it runs on the command line. So if
I wanted to like call a JSON API, I could say like HTTP space. And I would, you know, give it the URL,
whatever the, that is, maybe some additional data. You can even post data from the command line and so
on. And it comes back formatted, pretty printed, color coded everything. So it is, it's quite glorious.
You can create sessions and have those like authentic sessions persist across multiple calls.
You can do XML, you can do JSON, you can do HTTP, all the, or HTML, all these different things that it
knows about. It will color code and format pretty for you on the command line.
That's great. And this is, multiple, multiple operating systems.
Yes, absolutely. Yeah. So this, this works everywhere. This is just a Python three little library.
And that's the, the pie part, right? The Python. And so I'd spoke about postman before as being a
really cool way to test, APIs and just play around with them. But this is kind of like the CLI
version. Cause if you do that with curler or even with Python and requests and then you spit it out,
like it shows you it, but it's usually not well formatted. It's usually minified. It's not color
coded. So this is, this is pretty tricky.
The color coding actually makes it really readable. That's nice.
So if you're looking, if you've been using curl or w get a lot, check out HTTP, HTTP,
uh, the links in the show notes, it's on GitHub and it's got a, it's got a cool, a cool little
interface. I put the link to the homepage in there. Just click on that and you'll see a screenshot
comparison of that versus curl and it's night and day. It's great.
Well, the last thing I've got is, speaking of command lines and hard to pronounce packages,
um, it's a pip dep tree. there's a, a little utility, that you can do it with, pip install.
I think it's pip dep tree altogether. as in pip dependency tree, but just P I P D E P T R E E.
Right. Yes. And, it is a godsend for me. since for like, for this podcast,
I'm trying out stuff all the time, trying out new packages. And, also for like, right now,
I'm working on the plugin, chapter in the PI test book and I'm, I'm installing a lot of stuff
and I am using virtual environments, but I still, I don't really want to throw them away all the time.
Um, so I want to clean them out. But, if you just do a pip list, often I see a whole bunch of
stuff that I don't remember installing and it's because of all the dependencies.
And this pip dep tree just shows all of the things you've installed and what depends on what,
uh, when I look up and don't know what arrow is or where it came from.
Pip dep tree shows me that, Oh, I installed cookie cutter and cookie cutter installed Jinja2.
And Jinja to install there. Now I know.
Yeah. So yeah, that's very cool. Right.
Yeah. And it's nice. I like it. it's kind of, I wish that was just,
it should just be an option and, pip pip list, I think. So yeah, it really should be part of pip,
shouldn't it? But it's not. And so we have pipped up tree and I think that's cool. You can reverse it as well.
You can say, okay, this thing, what depends upon this? And it'll say, well, these three packages through some sort of
transitive closure of their dependency graph. These are the things that you, that, that you need this to be here for,
or you can do it the other way. And you can say, what is installed this, right? Like, or what does this thing depend upon?
Which is, it's pretty cool. So you can view it from either direction.
Oh, cool. I didn't know that.
Yeah. There's a -r for reverse. So hit it with the -r. Cool. Okay. So final thing we have for today is, a real testament to Python 3, to modern Python, to asynchrony.
You know, we've been hitting this async away, the power of asynchrony a couple of times. So I want to come back with a few comments from what people have talked about, but I also want to feature an article. And this is a really great article by the folks at Signet by AI, which is an AI platform that uses Python.
So basically the title that what we're going to talk about is not your father's Python, amazing Python frameworks.
They sort of went through what they had been thinking about when they created this company and said, look, we all know Python and we like Python, but it's super important that we can do crazy amounts of data processing.
Their product and investor has to handle hundreds of thousands of events per second. And, you know, they've been hearing the drumbeat that, you know, you can't scale with Python.
You need to switch to Go, et cetera, et cetera, et cetera. And they said, all right, well, let's, let's have a look and let's see how this is going to work out.
They evaluated Go and what the good and the bad of it was. They evaluated Python and said, let's look not at traditional Python, like the way, the sort of synchronous style of programming, but there's a number of really powerful async frameworks that we've covered, I think, at least two out of three of them.
So there's uv loop, which is pretty awesome. There's Sanic and there's Jepronto.
Okay. So Sanic and Jepronto, these are the web things that we've talked about tons and they're built on asyncio, just like this uv loop is, but uv loop is actually a re-implementation in Cython.
So the compiled version of Python, that's more than twice as fast as what's built into Python itself. Interesting, right?
So like maybe, maybe we should just like bring that feature into Python itself in some way to make asyncio twice as fast.
So they said, let's, let's look at this and evaluate it and decide if this scalability thing's going to work.
All right. And they said, we all know about the GIL. Is this a real problem?
So they ran, they ran some comparisons and did some work and it turns out like they've got some graphs of uv loop and the other frameworks, just like blowing away things like Node.js in terms of performance, keeping up with, I think, go on some, some use cases faster, some slower, but really very, very high performance.
And so after this really detailed write up with like numbers and everything, you know, graphs and analysis, they said, look, the future of Python is here.
Overall, it looks like fast asynchronous Python might be here to stay.
Now that asyncio really seems to be the default way that people are willing to work in Python and async and await has really caught on because of the non-blocking network and disk IO is usually the problem.
It turns out the GIL probably doesn't really get in the way of speed that much for most use cases.
It's cool.
Isn't that cool?
So they said, look, it's, it's working out great for us, Python three, and we've got the scalability we need.
No problem.
And we're happy we didn't abandon because traditionally hadn't been fast enough.
So I missed, somehow I'm missing this, which they looked at Jepranto and Sanic and uv loop.
Are they deciding on anything?
I don't know which one they decided upon.
I think uv loop is a little more established.
And uv loop is actually the foundation for Jepranto and Sanic.
So there's a bit of a mixing, right?
Like Jepranto and Sanic are extending these and certain.
It's pretty cool.
There's a nice comment, which I linked in the show notes for this section.
And there's somebody in there saying, hey, we went through the same basic thinking and here's how it worked out for us.
And they said, we're also doing this Async Python three thing, which is cool.
On Twitter, we got a message from Sasha Kurta.
And he said, basically, hey, Michael, hey, Brian.
I have this example where I was doing a bunch of HTTP client stuff.
And remember, we talked about aiohttp, the client side stuff, how much faster that can make it.
And he said, that's cool.
I was doing some scraping and whatnot.
And my particular project went from eight minutes, over eight minutes, doing requests to less than 45 seconds using the Async and await stuff with aiohttp.
Basically, the same code.
He was blown away.
Yeah, that's really cool.
And I'm glad that he shared that with us.
Yeah, I am too.
And of course, you drew the correct conclusion from this conversation.
That look at the, what is that, like 10-time increase in productivity you get by listening to Python bytes?
Yeah.
Yes, definitely.
All right.
You can save your company money, too, by listening to us.
Absolutely.
All right.
Well, that's it for this week's news.
You got anything, finally, you want to share personally?
Nope.
Just plugging away at the book.
Same here.
Plugging away the courses.
So thank you, everyone, for supporting all of our work, not just this podcast, but Brian's other podcast, his book, my courses, my other podcasts.
It's great to be doing this for everyone.
So thank you.
And thank you, Michael.
Yep.
See you later.
Thank you for listening to Python bytes.
Follow the show on Twitter via at Python bytes.
That's Python bytes as in B-Y-T-E-S.
And get the full show notes at pythonbytes.fm.
If you have a news item you want featured, just visit pythonbytes.fm and send it our way.
We're always on the lookout for sharing something cool.
On behalf of myself and Brian Okken, this is Michael Kennedy.
Thank you for listening and sharing this podcast with your friends and colleagues.