Latest / Talk Python To Me / #77: 20 Python Libraries You Aren't Using (But Should)
Transcript
- 0:00Many of you write to me and tell me how you appreciate the way my guests and I highlight a particular Python package at the end of each episode.
- 0:06Well, if you enjoy that little segment, you're going to love this episode.
- 0:10This week, you'll meet Caleb Hadding, who wrote a great book called 20 Python Libraries You Aren't Using But Should.
- 0:16He and I spent an hour digging into all the very powerful and interesting packages you probably haven't heard of, but will be super excited to use after you learn about them.
- 0:25This is Talk Python To Me, episode 77, recorded September 20th, 2016.
- 0:51Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 1:03This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy.
- 1:07Keep up with the show and listen to past episodes at talkpython.fm and follow the show on Twitter via at Talk Python.
- 1:14This episode is brought to you by Capital One and Intel.
- 1:17Thank them both for sponsoring the show by checking out what they're offering during their segments.
- 1:22Hey, everyone. I have a quick message for you before we get to Caleb and his book.
- 1:26In addition to writing this book for O'Reilly, Caleb also wrote a screencast course on Cython.
- 1:33And it looks to be one of the better Cython courses out there.
- 1:36So when he's talking about Cython, if you're really interested in what he's up to, be sure to check out his course, which is linked in the show notes.
- 1:43And O'Reilly agreed to give away a free copy of his course.
- 1:46All you have to do to be eligible is be a friend of the show.
- 1:49So be sure to visit talkpython.fm, click on friends of the show, enter your email address, and you'll be eligible to win.
- 1:56Now, let's talk to Caleb.
- 1:58Caleb, welcome to the show.
- 2:00Hi, Michael. It's great to be here.
- 2:02Yeah, I'm super excited to talk to you.
- 2:04We've got some really cool stuff around a book, a free e-book that you did.
- 2:09And I found it super interesting.
- 2:11So I think everyone else will.
- 2:12Basically, we're going to take the last question I always put at the end of my podcast.
- 2:17What's your favorite PyPI package?
- 2:18And turn that into an entire episode and just go deep on that idea, right?
- 2:22Okay.
- 2:22So before we get to that, though, let's start at the beginning.
- 2:24Where do you get into programming and Python, that sort of thing?
- 2:27Yeah, great question.
- 2:29So one of the other podcasts I listen to is the C++ podcast.
- 2:32And just about every guest on that show says that they started programming assembler in grade school.
- 2:38That was not my story.
- 2:39I didn't get into programming at all in school or high school.
- 2:43I started really as a hobby in university while I was studying chemical engineering,
- 2:47which is kind of an odd thing to do as a hobby when you're doing something completely different.
- 2:51But as the years went on, I kind of got more and more into programming.
- 2:55And it turned out that I did my master's degree in process control,
- 2:58which is like a subset of chemical engineering.
- 3:01And that was all in MATLAB.
- 3:03So it was pretty much all a programmed course.
- 3:06And that's really how I got into programming.
- 3:08And I learned that I really did not like MATLAB very much at all.
- 3:12Yeah, I spent some time there.
- 3:16I can sympathize.
- 3:17I don't love the .m files, no.
- 3:19Yeah, I got to know it really, really well.
- 3:21And yeah, I decided that I did not really want to carry that forward.
- 3:26And it was really when I started working in the first or second year that I started working.
- 3:30I started learning a couple of languages outside of work.
- 3:33And the one that I really tried to focus on was Java.
- 3:36And I signed up for a fairly expensive certification course.
- 3:40I think Java was around 1.2, version 1.2 or 1.3 or something at the time.
- 3:45And halfway through that course, I came across Andrew Kuchling's Python tutorial at the time,
- 3:51which I think was for Python 1.5.
- 3:53And it just blew my mind.
- 3:56I kind of had the realization that I couldn't possibly use Java anymore to do the kind of work,
- 4:02like data analysis work that I was doing, because it was so easy in Python.
- 4:06It was just a complete waste of time to develop all of these object-oriented structures around
- 4:11fairly simple data pipeline processing tasks.
- 4:14Yeah, that makes a lot of sense.
- 4:16I mean, Java has so much formality.
- 4:18And maybe, let's say it's maybe good for large applications.
- 4:22Maybe.
- 4:23Exactly.
- 4:23But it certainly doesn't make sense for small ones, right?
- 4:25Like you're talking about.
- 4:26Yeah, absolutely.
- 4:27There's definitely a place for Java for very large programs.
- 4:31But for the kind of things that I was doing, and especially for shorter programs involving data pipeline processing,
- 4:37Java is just way more than what you need to get the job done.
- 4:41And that was pretty much the end of Java for me.
- 4:43I never finished that course.
- 4:45I really got stuck into Python.
- 4:46And this was around 2001.
- 4:48So quite a few years ago.
- 4:49And then I watched Python become Python 2.
- 4:52And 2.4 was a big one for me.
- 4:55I used that for quite a long time.
- 4:56And so on.
- 4:57So yeah, that's pretty much how I got into Python.
- 4:59But along the way, I did use quite a few other languages fairly heavily.
- 5:03Fortran I used quite a bit as well because large chunks of the scientific world still use Fortran.
- 5:10I have written new Fortran 77 code.
- 5:12I have added that to the world.
- 5:14Oh my gosh.
- 5:15That's awesome.
- 5:16Yeah.
- 5:17And Delphi I used for quite a few years.
- 5:20My career has moved into and out of software development and into chemical engineering.
- 5:25I've kind of straddled both worlds for the past 15 years or so.
- 5:30And I did a stint as a software engineer in the hospitality industry for writing hotel administration software for about four years.
- 5:38And that was heavily using Delphi, the IDE from what used to be Borland and then became Embarcadero.
- 5:45So I got to know that language really, really well as well.
- 5:47Pretty much as well as I know Python, I would say.
- 5:50That's very interesting to me.
- 5:52I kind of regard Delphi and Python as almost polar opposites in many ways.
- 5:55A GUI is very easy in the one, not quite as easy in the other.
- 6:00Deployment is extremely easy in the one.
- 6:01Deployment is kind of difficult in the other.
- 6:03And so on.
- 6:04There are many parallels where I kind of see Delphi and Python as direct opposites.
- 6:10Another good one is the GIL, the global interpreter lock, which I think is really fascinating.
- 6:13In the Delphi world, for many years, one of the things that developers asked for over and over again was thread safety in the library.
- 6:21Because it was one of the huge talking points.
- 6:25They wanted the containers and the structures inside the library to be thread safe because it was too easy to get race conditions in threads because you could just spawn native threads and have them clobber each other's memory layer.
- 6:36And it's really fascinating to me that the exact inverse argument gets made in the Python world.
- 6:42That is funny.
- 6:43The presence of thread safety is the problem because it slows your code down.
- 6:48So, yeah, it's really interesting to be able to have a depth of knowledge in multiple programming communities because you kind of get a sense of maybe what is really important and what is spurious.
- 6:58Everything is a set of trade-offs.
- 7:00Yeah, exactly.
- 7:01That's the thing.
- 7:01That's what I was thinking.
- 7:02Nothing is accidental.
- 7:04Things are designed the way they are for good reasons.
- 7:06And they may not always be the best fit for every particular situation.
- 7:10Right.
- 7:11You learn a language that maybe it's not obvious initially.
- 7:13You don't know the history or whatever.
- 7:14But there was probably some deep thought that went into at least all the popular programming languages.
- 7:19Those things have evolved with lots of thought over time.
- 7:22Absolutely.
- 7:23Yeah.
- 7:23Yeah.
- 7:24Nice.
- 7:24Okay.
- 7:25Well, so a lot of Delphi, a lot of Python, a lot of scientific programming.
- 7:31What are you doing with Python and programming today?
- 7:33Like, what's your day job?
- 7:34Good point.
- 7:35So, I can give you a quick two-minute, well, one minute, let's say, run through of the things I've done.
- 7:41So, I started in chemical engineering with doing a lot of simulation work using off-the-shelf tools for that.
- 7:48And as time progressed, I started moving more towards the problems where there were no off-the-shelf tools.
- 7:52And for those, you have to write code.
- 7:54And I began using a lot of Fortran.
- 7:55Then I started incorporating Python into that.
- 7:57And then I took a break from engineering and went into software development where I used Delphi.
- 8:02But I also used Python as well for web development.
- 8:04Then I went back into engineering and I started writing simulation software for cold gasification, which is what brought me to Australia.
- 8:12And what's interesting about that job was for the first time, I really decided to use Python for the entire system, which means all of the number crunching stuff as well.
- 8:24And that's where Cython really came into the picture for me.
- 8:26I made the decision to use a full Python stack for that simulation work because it seemed to me that Cython was mature enough, really, to be able to give you the speed that you need to solve these mathematical problems in the background.
- 8:39And that definitely proved to be the case.
- 8:42It was a good choice on my part.
- 8:43Cython is not so much a break from Python, really, as an extension.
- 8:47But it gives you all of the native speed and control over the memory layout that you need if you want to make fast code.
- 8:53So I spent a couple of years doing that.
- 8:55Yeah.
- 8:55Would you say it's a little analogous to, like, inline assembler and C++ or something like that?
- 8:59You're like, just if this one loop could be faster.
- 9:02Let me just do this part fast.
- 9:04I think I would disagree with that.
- 9:06Okay.
- 9:06I began with that in mind.
- 9:07It's easy to look at it that way, but Cython is so much more than inline assembler.
- 9:11There's another way to look at it, which is you can write.
- 9:15You can get all the benefits of C by writing what looks like Python.
- 9:18And in one or two places, you just add some types onto a couple of variables.
- 9:21And you can get a hundredfold increase in speed.
- 9:24So whereas inline assembler is much more of a niche application of a different technology.
- 9:31Unless you can read assembler really easily, which I can't.
- 9:34Yeah, neither can I.
- 9:35Having inline assembler, yeah.
- 9:36Where Cython is not like that, by and large, Cython is as easy to read as Python.
- 9:42There are a couple of things that are different in the layout.
- 9:45But overall, you would find Cython as easy to read as Python.
- 9:48Okay.
- 9:49Sounds good.
- 9:50So back to what you're doing today.
- 9:51Yeah.
- 9:52So I've been working for the past couple of months on a contract for GPS tracking, which
- 9:56has also been using a full Python stack.
- 9:57And I was very lucky in that they were willing to go straight to Python 3.5.
- 10:01So I've been writing async I.O. code in Python 3.5 since February, which I feel very fortunate
- 10:07to have had that opportunity.
- 10:09And yeah, I'm starting a new job tomorrow from the date of this recording, working for a company
- 10:16called Console, which was formerly called IIX.
- 10:20And yeah, I believe my title has something to do with network orchestration, which is going
- 10:25to be a whole new thing again for me to learn.
- 10:28That is quite a shift.
- 10:29But that's really cool.
- 10:30And Python, of course, plays a super important role in that space.
- 10:33So it makes a lot of sense.
- 10:34Excellent.
- 10:36Yeah, absolutely.
- 10:36One of the big benefits of Python, just as a technology choice, is that you can use it
- 10:41just about every way.
- 10:42Yeah, that actually is really important.
- 10:44It's really important.
- 10:46Yeah, so I think that's a wide range of background and experiences.
- 10:51And it gives you a nice overview of the ecosystem and the standard library and all the different
- 10:57ways that Python makes you efficient, productive, and so on.
- 11:02And so you wrote a really cool book.
- 11:04You wrote it for O'Reilly, right?
- 11:05Yeah, that's right.
- 11:07Yeah, as a free e-book, I think.
- 11:09And it's called 20 Python Libraries You Aren't Using But Should.
- 11:14And I thought it was a really nice survey.
- 11:17Very BuzzFeed-y title.
- 11:19You know what?
- 11:21Anytime it starts with 10 or 20 or the seven things you should never say, you know it's
- 11:26a BuzzFeed.
- 11:26But it really is succinct and it lives up to the name.
- 11:30It's good.
- 11:31The idea for the book came from O'Reilly.
- 11:33Susan Conant at O'Reilly suggested it to me and asked if I would be willing to write
- 11:38the book.
- 11:38So the title was established before I got to the project and then I provided the content.
- 11:43Yeah, but the original working title was 10 Python Libraries You Aren't Using But Should.
- 11:47And I couldn't stop at 10.
- 11:50And in fact, if you count the major featured packages, there are 20.
- 11:55But you'll see throughout the text of the document that I refer to a whole bunch of other libraries
- 11:59as well in footnotes.
- 12:01Yeah, I thought that was interesting.
- 12:03Yeah, we'll talk about the 20 major ones and maybe even touch on some of the ones that you pull in.
- 12:08Like, for example, one of the web service bits, the implementation of the web service uses a few
- 12:14other libraries that we can talk about later, but they're not actually part of the 20, right?
- 12:18So there's, I feel like you get a really good, well-rounded view of what's out there.
- 12:24I was quite cautious about writing the book because it's a fairly contentious thing.
- 12:28The choices, the technology choices that people make, many people can be quite passionate about
- 12:32those things.
- 12:32And the brief for the book was, we want you to focus on libraries that other people don't know
- 12:37about yet.
- 12:38So that means I have to leave things out.
- 12:40And it also means that I have to leave things out that may be fairly popular, which means
- 12:43there might be quite a widespread degree of support for libraries that I'm not going to
- 12:48be mentioning.
- 12:48So I was somewhat apprehensive about that.
- 12:51So the libraries that I tried to focus on were things specifically that may not have much
- 12:56exposure, which is a very interesting idea for the book.
- 12:59I can't include things that are too niche that they could not be used for much, you know,
- 13:04very low applicability.
- 13:05But at the same time, I did not want to include things that were very well known because that
- 13:10defeats the purpose of the book.
- 13:11So I found it quite challenging to pitch it.
- 13:14It's the ones you aren't using, not the ones that you are, right?
- 13:16Exactly.
- 13:17Yeah.
- 13:18Yeah.
- 13:18It is a challenging one to go, okay, let's strip off that.
- 13:22Like if you say, what is the most popular library to do?
- 13:25You almost have to say, okay, well, except for that one, what else can we do?
- 13:29But I...
- 13:29Yeah, exactly.
- 13:30And I thought about that when I read the title.
- 13:32I'm like, oh, is this going to be a bunch of niche things that are like second fiddle
- 13:36to the stuff that you actually should be using?
- 13:38But no, I think it was really good.
- 13:39So maybe we could start by talking about the ones that everybody has installed already.
- 13:44That's the stuff that comes in the standard library.
- 13:46So you have, in the first chapter, you said, hey, look, there's a bunch of stuff you're
- 13:50not using that's built in.
- 13:51Developers with experience do tend to look in the standard library first because they've
- 13:55been burned by carrying extra dependencies, which after a couple of years may not be as
- 14:00well maintained.
- 14:00The impression that I have is that more experienced developers tend to lean more heavily on the
- 14:04standard library when choosing technology.
- 14:05Even if some of the time there may be other third-party packages that might be a better
- 14:10fit.
- 14:10That's a decision that gets made.
- 14:12That's really a trade-off.
- 14:13And I do the same.
- 14:14When I have to deploy an application to production and I know that this is a core service, I tend
- 14:20to lean more heavily on choosing things out of the standard library when possible, as opposed
- 14:24to adding third-party dependencies.
- 14:26Whereas newer developers tend to get whatever is the latest and greatest on PyPy and run
- 14:31with that.
- 14:31So what seems to me to be the case is that more experienced developers have a much better
- 14:37and deeper knowledge of what is available in the standard library.
- 14:39So even though the book was intended to be focused on third-party libraries only, I did
- 14:44want to squeeze in some of the absolute must-have, must-know standard library options, like the
- 14:50collections package, which is the first section in this chapter.
- 14:53If you watch any of Raymond Hittinger's talks, he plugs the collections module heavily, as
- 14:59well he should, because it's awesome.
- 15:01Yeah, I do feel strongly about that, that people really should know more about what's in the
- 15:06standard library.
- 15:06And my original version of the book had more of it in, but we decided that we wanted to focus
- 15:12the book more on the third-party stuff.
- 15:13So it got trimmed down.
- 15:15Sure.
- 15:15I think that makes a lot of sense.
- 15:17Yeah, that makes a lot of sense.
- 15:18Partly, I mean, there's nobody who is the advocate for the thing in the standard library.
- 15:23It's just built in.
- 15:24But when somebody makes their open source library, they set up some GitHub Pages thing, and they've
- 15:28got some cool logo.
- 15:30And, you know, like it's, there's somebody promoting it in a sense.
- 15:33And so I can see that.
- 15:35Yeah.
- 15:35So a couple of the things that you talked about in the collection library, one of them, which
- 15:39I think is pretty interesting and timely, is ordered dict.
- 15:43Yeah.
- 15:43So what's interesting about this section is that it may become redundant in December.
- 15:48I don't know if you've been following the discussions on the Python dev mailing list, but the new
- 15:54dictionary in Python 3.6, which I think the release date for the final version is December, the
- 16:00dictionary is going to become ordered.
- 16:01Whether that is going to be advertised as a requirement for the language spec, or whether
- 16:06that's just going to be an implementation detail remains to be seen.
- 16:09But yeah.
- 16:11Sure.
- 16:12Yeah.
- 16:12And so every now and then you'll see people building special dictionaries for Python that
- 16:19are ordered.
- 16:20For example, the MongoDB library exchanges dictionaries at serialization, and the changing of order
- 16:25causes more rights on the server for documents than if it doesn't.
- 16:29And so they may went and created their own, and we've got this order dict.
- 16:32So what's some of the problems you run into with like the regular dictionary?
- 16:36Or like, why do you care about ordering, I guess?
- 16:38The main use case for ordering that I've come across is usually when processing things that
- 16:43are really mappings in a sequence, and they need to be processed in the sequence in which
- 16:47they appear.
- 16:48So I think the example I gave in the text is, yeah, and a common example is processing lines
- 16:52in a file where the lines map to something else.
- 16:54And you want to serialize them or persist them in some way, retaining the order that they appeared
- 17:00in the original list.
- 17:02Right, like maybe like a CSV you're going to load and you're going to say look up by
- 17:05like some ID, which is a column.
- 17:07If you write it back, you want to be able to save it the same order and not have to maintain
- 17:10like two data structures or something.
- 17:12Yeah.
- 17:12Yeah, that's right.
- 17:13Exactly.
- 17:14Okay.
- 17:14So there is right now in all the versions of Python, the collections.order dict, which is
- 17:21a specialized dictionary that solves this problem.
- 17:23It just so happens if you live right out at the very edge of new Python, you might not need
- 17:29that in December, but a lot of people don't live there.
- 17:32Right.
- 17:32So I think it's still totally relevant.
- 17:34Yes.
- 17:34And from the discussions that I've been seeing on the Python dev mailing list, it probably
- 17:38is going to remain in the library.
- 17:40What the latest that I've seen is that the order of keyword arguments in function calls is
- 17:46going to be guaranteed to be maintained.
- 17:48But the requirement for normal dictionaries to be ordered may not be a specification of the
- 17:54language spec, which means that other implementations of Python may not need to maintain that.
- 17:59Right.
- 17:59Okay.
- 18:00So that's quite interesting.
- 18:01One of the caveats that I mentioned about order dict towards the end of the section with
- 18:05the big red triangle is beware creation with keyword arguments, which is exactly this problem.
- 18:10When you create an order dict and you supply keyword arguments as you would with maybe a regular
- 18:15dictionary, the problem is that the order is maintained with your specification because the
- 18:21keyword arguments first get created as a regular dictionary before they get created as
- 18:24an order dictionary.
- 18:25And that's going to be changing for sure in 3.6.
- 18:27Okay.
- 18:28Oh, excellent.
- 18:29That's good to know.
- 18:29Yeah.
- 18:30Because that happens at the call site before the order dict class ever gets any information.
- 18:36It's just given a dictionary and it can do what it can do, but it's too late.
- 18:39The order has already changed, right?
- 18:41Yeah, exactly.
- 18:42That's right.
- 18:42And I think the other guarantee is that the dunder dict entry in classes is also going
- 18:49to have a guarantee of the order being maintained.
- 18:51Even though it's implemented as a regular dictionary, what the language spec requires and what actually
- 18:56happens in practice are two different things.
- 18:58So the developers of Python are trying to maintain the language spec as a spec even for other implementations
- 19:03besides CPython, which is difficult to kind of keep in your head when all you work on is CPython,
- 19:08which is largely the case for me.
- 19:10But yeah, they're dealing with bigger problems than just whatever goes into CPython.
- 19:16Yeah, that's an interesting thing to keep in mind because we often just think of CPython
- 19:20equals Python language, but there's a lot of other implementations and extensions and forks
- 19:25and whatnot.
- 19:26Yeah, yeah, exactly.
- 19:27Capital One has a special message for you.
- 19:43They need Python pros who love to work with data.
- 19:46Put your Python experience at work at Capital One and help them use data to make life better
- 19:50for millions of customers.
- 19:51Capital One is employing the latest tools and approaches to do data analytics and data science
- 19:56from the ground up.
- 19:57They're smart, creative professionals who love to explore new ways to interact with data.
- 20:01They're interested in figuring out novel, advanced Python techniques and even more interested
- 20:06in finding more people who will help them do that.
- 20:09When you join their state-of-the-art Python community, you'll work with people you really
- 20:12like, people who might be listening to this podcast right now.
- 20:15Relentless innovation is their way of life.
- 20:17Make it yours at Capital One.
- 20:19Visit jobs.capitalone.com slash talkpython to learn more and apply today.
- 20:24So another one I would say is also one of, if I had to pick the most useful thing to come
- 20:34out of the collections library, I would say it's probably named tuple, which you highlight
- 20:38in your book as well.
- 20:38Yeah, yeah.
- 20:39Named tuple.
- 20:40Named tuple is kind of interesting.
- 20:42I have recently started using it directly when creating tuple structures.
- 20:46But most of my experience with named tuple really has been converting old code that used
- 20:50regular tuples into using named tuples just to improve the maintainability aspect of that.
- 20:55And it is very powerful in that respect.
- 20:58Yeah, it doesn't change the performance much.
- 21:00And it's an easy thing you can do because named tuples are compatible with the existing code,
- 21:07but they definitely add a layer of maintainability, right?
- 21:09So if you have a regular tuple and it's three things and you need to put some new item in the
- 21:14middle to make it four, well, the code that was going, you know, T bracket two now is not
- 21:20true, not accurate anymore, right?
- 21:22But if you could refer to them by the names, the property names, that's fantastic, which
- 21:27is what named tuples adds.
- 21:28Great.
- 21:28Yeah, that is a good one.
- 21:30Yeah.
- 21:30One that I've done a lot less with is Context Lib.
- 21:33What's the story of that?
- 21:35Ah, so what did you think of my example?
- 21:37Just for the listeners, the example that I gave, the code snippet under Context Lib, is
- 21:42creating a simple context manager that measures the time.
- 21:45Well, it records the time before and after the execution of the body of the context manager
- 21:50and then gives you a way to calculate the performance of that section.
- 21:54I haven't gotten much feedback about the book yet because it is fairly new and I was curious
- 21:58what your opinion was.
- 22:00Well, I got to say, it did take me a moment of going back and let me look at this context
- 22:06manager implementation.
- 22:07It's just only three lines of code.
- 22:11I can just, you know, basically the idea is you create a context manager instance by calling
- 22:16this method and it will, when it enters, capture the start time.
- 22:20When you leave the width block or suite, it captures the end time and then it tells you
- 22:25how much time had passed.
- 22:26And so the implementation is T equals get the perf counter.
- 22:30T zero equals perf counter.
- 22:31Yield a lambda, which does a computation and then compute the value that is actually used
- 22:41in the lambda above.
- 22:42And that, I was a little bit taken aback by that.
- 22:46It was interesting.
- 22:46Yeah.
- 22:47I was worried that it was perhaps a little bit too complex.
- 22:50And I didn't want to, the fact that the use of the lambda, I didn't want the use of the
- 22:53lambda to overshadow the demonstration of how the context manager works.
- 22:57But basically where the yield comes in is where the body of the context manager gets executed.
- 23:03And if you return something from the yield, that's pretty much what you get at the end
- 23:07of the line when you say with timing as thing.
- 23:11The thing is what gets yielded out of the context manager.
- 23:13And the little bit of cleverness in this particular example is that the lambda is a closure over
- 23:19the namespace inside the timing function.
- 23:22So it captures the storage location of T one and T zero.
- 23:26So only when you evaluate the lambda later, do the values of T one and T zero actually
- 23:31get used.
- 23:31Yeah.
- 23:31It's quite clever.
- 23:33Yeah.
- 23:33Yeah.
- 23:33This particular example is not imaginary.
- 23:36I use it quite a lot.
- 23:37Yeah.
- 23:37It's nice.
- 23:38I appreciated it because it made me think and stop and not just read.
- 23:42Yep.
- 23:42Okay.
- 23:42Yep.
- 23:43Okay.
- 23:43Oh, wait a minute.
- 23:44Not necessarily.
- 23:44Okay.
- 23:45What's going on?
- 23:46And you know, that was cool.
- 23:47Like it's nice when code makes you do that.
- 23:48If it's not just because you're confused and it's too messy or whatever.
- 23:52It's cool.
- 23:53Yeah.
- 23:53My editor at O'Reilly, Dawn Shanafelt, she was really good about making sure that each of
- 23:59these steps were explained in more detail.
- 24:01And the editors at O'Reilly are really good.
- 24:03They can pick up based on the style of your writing, whether you think you've explained it
- 24:08sufficiently or not.
- 24:09And they can prod you to say, are you sure you've explained this, but it seems like you
- 24:13were a bit terse, perhaps add a few more points.
- 24:15So all these bullets and points on the side where everything is spelled out in great detail,
- 24:19that wasn't driven by me.
- 24:21That was driven by the editors.
- 24:22They're really, really good at what they do.
- 24:24Yeah.
- 24:25You did a good job as a team of breaking down what the steps meant.
- 24:29Yeah.
- 24:29That's cool.
- 24:29So the other thing that you, that was built in was the concurrent.futures module in Python
- 24:363.
- 24:36And I thought that was a really interesting way to think about sort of a unifying API between
- 24:43process-based parallelism and thread-based parallelism.
- 24:45Yeah.
- 24:46I wanted to push that point because I think that's, that is the underutilized aspect of
- 24:50concurrent on futures is that it gives you this, this really easy lever to switch paradigms.
- 24:55For some processes, thread-based programming is valuable.
- 24:58And for others, process-based parallelism is, is equally valuable.
- 25:02And you get the same interface really just about.
- 25:05So you can switch between those two paradigms really quite easily after the fact, which is
- 25:09really interesting.
- 25:09Usually for complex code involving parallelism, you end up with a structure that is hard to
- 25:15change to fit it in a different paradigm unless you do a rewrite.
- 25:17And the fact that concurrent.futures gives you the same API for both thread-based work and
- 25:22process-based work is a really cool superpower.
- 25:25Yeah, it totally is.
- 25:26And maybe, you know, it definitely is a simplification because when you start talking about threading,
- 25:32there's so many edge cases and interesting variations.
- 25:34But maybe the general rule of thumb is if you spend most of your time waiting on the network,
- 25:40then thread-based parallelism is probably good, especially if you're sharing a lot of data as
- 25:45well.
- 25:46And if you're doing a lot of computational stuff because of the GIL and you're not using
- 25:50Cython or something, then, you know, you can't really parallelize that very much.
- 25:54So multiprocessing and multiple processes for that is maybe a much better way to go.
- 26:00But yeah, with the thread pool executor and what was the other one called?
- 26:06The process pool executor.
- 26:09Those two have exactly the same API.
- 26:11And so if you write your code against those instead of directly against multiprocessing and
- 26:15directly against the thread API, you literally change your import statement and it changes
- 26:20where stuff runs and how, which is pretty cool that you try it out.
- 26:23Yeah, that's really good.
- 26:25One comment that I also want to make is if I make the choice between whether to use threads
- 26:30or whether to use processes, it's not because of the GIL.
- 26:33Because as you mentioned, Cython lets you drop the global interpreter lock.
- 26:38That's not an issue for me.
- 26:40I can write my number crunching code in Cython and use Python's normal threads and still access
- 26:46all of the cores.
- 26:46The distinction for me between whether to use process-based parallelism or thread-based is
- 26:50really about whether I need to use, I need to be able to access the entire memory space
- 26:54in the process.
- 26:55So that is the main distinction about whether things are okay to be separated by process or whether
- 27:00I really need the entire memory space to be accessible by all of the parallel parts of
- 27:05execution.
- 27:05So if that is the case, for example, if the batch of work that you need to operate on has
- 27:10to all fit in the same memory space inside a process and you need to work on different sections
- 27:15of memory concurrently, then I would use threads.
- 27:18The presence of a global interpreter lock, while it's interesting, is not really a bottleneck
- 27:23anymore in CPython because of Cython, because it makes it so easy to drop the GIL.
- 27:27Right.
- 27:27Awesome.
- 27:28Okay.
- 27:28Yeah.
- 27:28That's a really interesting point.
- 27:30And we will definitely be coming back to Cython.
- 27:32But if you're working on some data structure that is really large and the threads are updating
- 27:37multiple parts of it at the same time, then yeah, you want to keep that in the same process
- 27:41space.
- 27:42Yeah, absolutely.
- 27:43It's really difficult to make that work with process-based parallelism.
- 27:46I have been looking at ways of doing that, and I would like to find more about that,
- 27:50about using memory mapped files to share memory between processes.
- 27:54But I don't have much experience with that yet.
- 27:56That's something that I would like to get into more.
- 27:58Yeah, that would possibly be a solution.
- 28:00But yeah, I don't know what the performance looks like.
- 28:03It's interesting.
- 28:04Okay.
- 28:05Yeah, me neither.
- 28:05All right.
- 28:07So the next one that was built in was logging.
- 28:09You said, you know, look, it's time to get over the print statement.
- 28:13If you're trying to actually do debugging stuff, don't just spread it out.
- 28:16Like, it's almost the same as you do logging, but you get a lot more.
- 28:18Yeah.
- 28:19So the experience that I have, this is quite a few years now.
- 28:23The experience is I write out a new module or a new script using print statements.
- 28:28And a couple of hours later or a couple of days later, it becomes something that I actually want to use and depend on.
- 28:32And then I go back through the same code and I change all the print statements to logging statements.
- 28:36And yeah, for the last couple of years, I've now just gotten into the habit of just beginning with logging.
- 28:40You just put in the boilerplate, the setup line, and then creating your logger, and then you just run with that.
- 28:48Yeah, it's pretty straightforward, right?
- 28:50You import logging, you call logging.getlogger, and then you can say logger.debug, logger.info, warning.
- 28:57And I agree with your sentiment.
- 28:59You know, where I find it, I'll be totally happy with print for a while, and then I want to make the code that I was playing with a library and not an application.
- 29:08Right.
- 29:09Yeah.
- 29:10And then all those print statements, it's like super hard to make them go away or to configure them.
- 29:14It's just like, ah.
- 29:15All right.
- 29:16Just a removal.
- 29:17Just a removal.
- 29:18Yeah.
- 29:18So logging, excellent.
- 29:19Another one that I really like in this space, although this is the built-in ones, is I really like logbook.
- 29:25I think logbook is a nice external one.
- 29:27But like you said, having stuff built in is great.
- 29:30Okay.
- 29:30That's a good tip.
- 29:31I didn't know that I'm going to make it.
- 29:32Yeah, I think that's Armin Roeniger.
- 29:34I can't entirely remember, but I have to look.
- 29:37It's really good.
- 29:38Okay.
- 29:39Let's see.
- 29:40So another thing that you might want to do is run something on a scheduled basis, right?
- 29:47Like every five minutes, I want to do this thing, or exactly on the hour, I want something to happen.
- 29:53And the OSes have built-in ways to do this.
- 29:57And I mean, I guess you could like spawn a thread or something to watch.
- 30:01But there's some cool stuff built in for that, right?
- 30:03Yeah, that's right.
- 30:04So you're talking about the shared module, S-C-H-E-D.
- 30:07This is a really good example of how you have to be aware of your biases.
- 30:13For people who only ever work on POSIX systems or Linux, for example, right?
- 30:17Cron is always there.
- 30:18It does what it does really well.
- 30:20There's a wealth of information available on the internet for how to use Cron.
- 30:23So it seems bizarre that there would be this thing in Python that does exactly the same job.
- 30:28But the thing is, Cron doesn't run on Windows.
- 30:30Windows uses a separate system.
- 30:32However, because Python includes the shared module, you can get the same or very similar functionality
- 30:38to what you might get in Cron or the Windows task scheduler.
- 30:41With a cross-platform Python module.
- 30:43And that's really, really powerful if you're writing some service or library that needs to do these jobs on a timer.
- 30:49Or at a particular time of the day or so on.
- 30:52I look at shared as a really great example of what Python provides in terms of cross-platform support
- 30:57for getting this kind of functionality, but in a cross-platform way where you can use the same code base on multiple platforms.
- 31:02Yeah, and it's really nice.
- 31:04And you basically set up the scheduler and you give it a priority and a frequency.
- 31:09And then you say, and call this function whenever it's time.
- 31:12And you can do that in either a elapsed time, like 10 minutes from now or every five minutes from now.
- 31:18Something like that.
- 31:19Or you can do it on a more, like once a minute exactly at the minute.
- 31:25Right?
- 31:25Yeah.
- 31:26Nice.
- 31:27Yeah, you can control completely when the target time is, or happens to be.
- 31:31I can definitely see Shred becoming a part of the robotization, I guess, of the internet in a big way.
- 31:41Automating things and creating bots and timers and work queues and so on.
- 31:46Yeah, it's beautiful if you've got some embedded device running your Python code and needs to get home every now and then.
- 31:53Just set that up, right?
- 31:54Yeah.
- 31:54Yeah, absolutely.
- 31:55Nice.
- 31:56I see we've got to the end of the standard library section.
- 32:00We have?
- 32:00There was one.
- 32:01Yeah.
- 32:01There was an additional one that I had in an earlier draft of the book, but we dropped it because it was too short, I guess.
- 32:09And that's shlex.
- 32:11There's a module called shlex in the standard library, which I wanted to include for no other reason than it has a split function, which will split strings like the normal split, except that it will retain quotes around sections.
- 32:24So you can group chunks of words with quotes, just like you might imagine shell processing would process your commands.
- 32:32If you put quotes around sections of things, then it treats those as one thing.
- 32:35So the shlex module in the standard library has a split function that does that for you as well.
- 32:40Oh, nice.
- 32:41Yeah, you can almost escape the things you're putting on by putting in quotes.
- 32:47Okay.
- 32:47Yeah, awesome.
- 32:48You don't have to do any quote processing yourself.
- 32:50It's already in the standard library.
- 32:52Yeah, excellent.
- 32:53Okay, very nice.
- 32:55So that was sort of the look inside of what's in the box if you just have Python.
- 33:00And then you said, all right, let's look outside at external packages and why not start with a better way to install packages?
- 33:05Yeah, absolutely.
- 33:07So for anyone who doesn't know about Flit and you found that the normal process for creating and publishing a Python package to be arduous, Flit absolutely is the thing that you need to look at because it automates, for simple packages, it automates almost entirely everything that you need to do.
- 33:25It's by Thomas Klaver.
- 33:27He's very active in the Python scientific community.
- 33:30And yeah, I think it's just awesome.
- 33:33I'm using Flit at the moment for several of my own smaller projects.
- 33:37Yeah, it's cool.
- 33:37So if you want to submit something to PyPI, you have to create a setup PY with a lot of various settings, you know, set the license in the right way so people can discover it and who's the author and where's the documentation and what version it is, all those kinds of things.
- 33:53And if you install Flit, you can basically say, I'd like to initialize this package and it just lets you, it basically takes you through a Q&A and then it generates the things it needs to upload your package, right?
- 34:03That's right.
- 34:04Yeah.
- 34:04And the Q&A is pretty short.
- 34:05I think it's four questions or something like that.
- 34:07If you, another good tip is the cookie cutter project by Audrey Roy Greenfeld.
- 34:13And there's a cookie cutter project for creating a skeleton for a Python package.
- 34:18And it's quite eye-opening when you, when you run the cookie cutter and you see how many files it creates in a folder.
- 34:24There's a manifest.in and there are several other extra files that are used just to, just to create and publish your package.
- 34:30Whereas Flit does away with all of that.
- 34:32You've really just got the Flit.ini.
- 34:33Nice.
- 34:34And you can get your package on PyPI.
- 34:36And it's quite, quite simple stuff in the INI file.
- 34:40It's not outrageous, right?
- 34:41Yeah, exactly.
- 34:42Nice.
- 34:43And so then you can say things like Flit wheel upload, and it'll just take whatever active package.
- 34:48package you happen to be in with the version specified in the files and just package it up and send it, right?
- 34:53Yeah, exactly.
- 34:54I haven't tried Flit yet for packages with extensions.
- 34:58So, yeah, I don't want to say that it can do that as well, because I just haven't tried that myself.
- 35:03But that's something that I do want to dig into as well.
- 35:05Yeah, absolutely.
- 35:06Okay.
- 35:07Well, another thing that is very common is to create some kind of shell utility or app that has some kind of terminal output.
- 35:16And there's not a lot of facilities in the standard library for, like, Keller output and nice sort of antsy style graphics, if you will.
- 35:27So, one of the things you talked about is Colorama, which I thought was pretty cool.
- 35:31I've looked at it a few times.
- 35:32Yeah, I feel very strongly about Colorama.
- 35:35And the reason is because we, generally speaking, we write software for people, for other people or for ourselves.
- 35:43And you see the output from software, particularly in the terminal.
- 35:46You have to deal with that a lot.
- 35:47And I think that making that output friendlier and easy to read and easy to understand context, but, for example, by using green for good and red for bad, makes it a lot easier to use programs, really.
- 35:59If we have to write software that works in the terminal as opposed to writing graphical user interfaces, there's no reason why we can't make that output appear better.
- 36:08The prompt toolkit is another good library for making interactive user interfaces in the terminal.
- 36:15And I didn't cover that in the book, but I think later we come to the PT Python interpreter, alternative interpreter.
- 36:22So, we'll get to that later.
- 36:23But that is part of this.
- 36:24The use of color, I strongly believe, can help to make better user interfaces on the command line.
- 36:30Oh, I totally agree with you.
- 36:31Yeah.
- 36:31Yeah.
- 36:32What makes Colorama so great is that they completely abstract away, again, platform differences.
- 36:37So, your code that uses Colorama will use the correct antsy codes in a bash shell, but when you're writing it in a Windows command prompt,
- 36:45it will also use the correct color codes for that environment.
- 36:47So, I think that's really powerful.
- 36:49You're not really committing to a particular platform by using Colorama.
- 36:52And it is a well-maintained package that I think support goes back to 2.64 and they include 3.5 as well.
- 36:59Nice.
- 36:59And you said also that you recommended Color Log as a way to add coloring to your log messages.
- 37:05So, like, warning is one color, error is another, and so on.
- 37:09Yeah, exactly.
- 37:10And it's two or three lines, and you get that functionality, and all your existing logging messages will just get those colors.
- 37:16It's a really easy drop-in replacement just to make sure that you have colorization for all the different logging levels of your logging messages.
- 37:23Yeah, I think it's great.
- 37:24You see something red go by, you know, obviously.
- 37:26Pay attention, right?
- 37:27It's great.
- 37:28Exactly, yeah.
- 37:29Or bold red, I see, for critical.
- 37:31Yeah, absolutely.
- 37:33So, another thing that you talked about on the terminal, the CLI, is accepting arguments.
- 37:41So, built-in, we have argpars, but there's maybe some better ways.
- 37:46And one of the ways you recommended was the Begins library.
- 37:48Yeah.
- 37:49What's Begins?
- 37:50Begins is a library that I first heard about at PyCon Australia in 2014.
- 37:54The author, Aaron Isles, gave a very strong demonstration of Begins.
- 37:59And it struck me at that time how much you can really do with Python if you exploit all the features of the language that are available to you.
- 38:08So, the point that I made in the book was that Begins, just from the perspective of an API design, is extremely aggressive with exploiting everything that Python provides to you.
- 38:19And, for example, the annotation, the variable annotation format in the function definitions, Begins uses those annotations for the docstrings of each of your parameters so that you don't have to add that anywhere else.
- 38:30And I really like the way the Begins API was designed to give you as much functionality as possible for as little input from you.
- 38:38I like that trade-off very much.
- 38:40Yeah.
- 38:41It's really nice.
- 38:41What I have heard from many people, though, is that they much prefer a slightly more rigorous specification format like what you can get now in the click library.
- 38:52And docopt also gets a lot of love, which is another way of creating your command line interface by, not docopt, I forget the name now.
- 39:00But there's another library where you can write out the help message of your CLI tool.
- 39:07Yeah.
- 39:07And it'll do it in reverse.
- 39:08It's basically the reverse of Begins.
- 39:10I think that is docopt.
- 39:11Yeah.
- 39:12Oh, okay.
- 39:12It is docopt.
- 39:13Yeah.
- 39:13So, it's the reverse of Begins.
- 39:15You write out your help message that will be printed when the user types help, and then it infers what all your parameters are.
- 39:20That is also fairly popular.
- 39:22Even so, I have found that for my own small scripts, Begins gets me going much, much faster.
- 39:27And even subcommands are very, very easy to enable.
- 39:32Right.
- 39:32So, basically, you have some method.
- 39:34You want to give some kind of CLI to it.
- 39:36It takes some parameters, and you just give it a decorator or a subcommand decorator.
- 39:41And now it is accessible, and it's part of the help text and all that.
- 39:44That's correct.
- 39:45Yeah.
- 39:45Yeah.
- 39:45Excellent.
- 39:46We all love Python for its tremendous productivity benefits, but getting the best performance takes some work.
- 40:06What if you could get out-of-the-box, easy access to high-performance Python?
- 40:11Intel distribution for Python developers delivers just that.
- 40:14Get close to 100 times better performance for certain functions when using NumPy, SciPy, scikit-learn, linked with optimized native libraries like Intel Math Kernel Library, access efficient multi-threading, and Python projects like Numba and Scithon.
- 40:28Try the Intel distribution for Python and experience performance today at talkpython.fm/Intel.
- 40:34And profile your Python and native C, C++ applications for performance hotspots with Intel VTune amplifier.
- 40:42With Intel, it's all about performance.
- 40:52All right.
- 40:53All right.
- 40:53So let's move into the GUIs, the graphical interfaces.
- 40:57And one of the first things that you talked about is creating interactive, dynamic graphs and things like that.
- 41:05And while Matplotlib plays a big role there, you also talked about PyQT graph.
- 41:12Why did you pick that over, say, Matplotlib?
- 41:14The primary reason why I have selected PyQT graph over Matplotlib is for interactivity.
- 41:20It's hard to imagine that you could have a highly performant charting library for Python, but that is exactly what PyQT graph is.
- 41:27It's based on QT as the widget toolkit that runs in the back end.
- 41:31But the interactivity is really good.
- 41:34You can have graphs that draw spectra running at 50 frames a second quite easily.
- 41:39And you can drag and zoom and pan all the while the animation is happening.
- 41:43So you could have a data stream where you're plotting the data as it comes through live.
- 41:48Oh, wow.
- 41:48Whereas with Matplotlib, that degree of interactivity is not really there.
- 41:51I see.
- 41:52It's not because of a lack of ability.
- 41:54It's because Matplotlib has been designed towards producing publication-ready type charts in a similar way to what Matlab's charting facilities were designed.
- 42:04Whereas PyQT graph has been approached with a whole different use case in mind.
- 42:09So in my chemical engineering work, PyQT graph has been very valuable for me to be able to plot live data and then examine it in real time, pan and zoom and move my moving data sets around.
- 42:21That's awesome.
- 42:22Yeah, if that was all that PyQT graph provided, that would already be enough.
- 42:27And that was my largest use case for it.
- 42:29But it has a fairly feature-complete widget library in the background that lets you plot, not plot, but create widgets on the fly for arbitrary Python data structures.
- 42:40So you can get input cells and sliders and so on that can manipulate your data.
- 42:44And PyQT graph provides all of that as well.
- 42:47Yeah, that's excellent.
- 42:47Yeah, if you want to embed some kind of like live data thing into your app, it sounds really cool for that.
- 42:52Yeah, it definitely is a good choice.
- 42:54And especially if you're already using PyQT, PyQT graph is a drop-in replacement.
- 42:58Yeah.
- 42:59You can add its chart windows as a widget inside your existing PyQT app.
- 43:03Yeah, that's really great.
- 43:04And there's a lot of interesting talk around PySide coming back to the same company that does Qt.
- 43:12And that's, yeah, it sounds like it's going to be a real, like this is a vibrant growing area.
- 43:18So that's great.
- 43:19Yeah, I've got my eye on the resurgence of PySide as well.
- 43:22Yeah, cool.
- 43:23Yeah, I'm totally, totally excited for that.
- 43:25So then the next thing that you talked about was one way to build your apps is using these graphical frameworks.
- 43:32But a very popular one, even using CSS front-end frameworks like Bootstrap and stuff, is web development.
- 43:38So there's another interesting library that lets you have Python logic in a desktop application,
- 43:45but actually presents the user interface through a GUI.
- 43:48You want to tell us about that?
- 43:50Yeah, so I also included PyWebView, which is something that I found while doing the research for the book.
- 43:55It's not something that I had used before.
- 43:57But I was blown away at how such a powerful tool exists, and it could not be better known.
- 44:03Most people know about the Electron framework and the Chrome-embreaded framework,
- 44:07which can also make these desktop apps that rely on the WebKit engine to provide the visualization layer.
- 44:14The interesting thing about PyWebView is that it doesn't require you to bundle something like Electron with your app.
- 44:20It just uses the native browser.
- 44:22I see.
- 44:22Which is really amazing.
- 44:23That is amazing.
- 44:24Is it cross-platform?
- 44:25Yeah, it's cross-platform.
- 44:26So it will use Internet Explorer or Edge on Windows, and it'll use the WebView widget on OSX, which is what powers Safari,
- 44:35and then on Linux it will use whatever is native there.
- 44:37Interesting.
- 44:38Yeah, I may be pushing up to the edge of the things I've actually played with.
- 44:42But the Electron stuff, in order to implement that and put the logic in it, that's JavaScript, right?
- 44:52Correct.
- 44:53So if you want to have, well, no, not necessarily.
- 44:56So if you just imagine a normal web application where you have your front-end layer that runs what we would say as in the browser with your CSS and your HTML and your JavaScript,
- 45:08and then you have your back-end layer, which provides an API that receives REST calls or whatever, which we would typically write in Python.
- 45:15You do exactly the same thing, but you just package it in one bundle as a desktop application.
- 45:19Nice.
- 45:19So from the perspective of the viewer, with PyWebView in particular, you don't really know that you're in a browser because you don't have all the same features and trimmings and buttons and menus that you get in a browser.
- 45:29All you really get is the WebView window, and then you get to put in there whatever you want.
- 45:33But you can power that with all these same technologies.
- 45:35So you can specify the layout of your screen using HTML and style it with CSS.
- 45:42And if you want some interactivity in the graphical layer itself, then you would have to write that with JavaScript as you would with a normal web application.
- 45:49But your Python, that can provide much of the logic and back-end processing of what your use interface is advertising, can also run alongside that application on your desktop.
- 46:01So from the perspective of a user of such an application, they would be oblivious to the fact that Python was being used at all.
- 46:07Yeah, it looks really interesting.
- 46:08And I kind of prefer CSS and HTML for GUI design.
- 46:13So I may have to try this out.
- 46:15Definitely worth looking into.
- 46:17I definitely recommend it.
- 46:18In the example that I used, I also used another Python library called Dominate, which allows you to create the HTML DOM and structures within the DOM directly from inside Python code.
- 46:29But that was just me being too cute, I guess.
- 46:32Just because you can.
- 46:32You can also.
- 46:33Yeah, exactly.
- 46:34You can just write your HTML and CSS out as you normally wouldn't load that.
- 46:38And that works fine.
- 46:38Right.
- 46:39So you would.
- 46:40Could you do something like have like a Chameleon or Jinja 2 template and something like that and pull that in?
- 46:47Yeah, absolutely.
- 46:48Okay.
- 46:48Definitely.
- 46:49No question.
- 46:49And the big benefit of PyWebView over using Electron is, again, that you don't have to distribute a fairly large browser engine alongside your app.
- 46:59Yeah.
- 47:00Excellent.
- 47:01If you can find a way to bundle just the Python parts of your app, when you run it, it will use the native web widget of your target operating system.
- 47:10Excellent.
- 47:11Okay.
- 47:12I really like that one.
- 47:13And I definitely want to have a look at it as well.
- 47:16So moving on to sort of the systems management, system tool stuff.
- 47:21The first one you brought up was an example of something I was trying to do in one of my online classes that I was building.
- 47:27And I'm like, oh, why is this so hard in the built-in process stuff?
- 47:34And that's about managing processes with PSUtil.
- 47:36Yeah.
- 47:37So worry no more because there's a library called PSUtil that does everything you could possibly want in terms of accessing information about the system and more.
- 47:47I have a feeling that PSUtil is going to be bad for the business for many monitoring companies, server monitoring frameworks, because it's so easy to run PSUtil in a daemon on your server and get it to send information back to you about which process is consuming how much memory.
- 48:03If your particular application is misbehaving in some way or if the system itself has started to change how it is supposed to be operating, PSUtil makes all of that really easy.
- 48:14I reckon in a day or two, you could probably whip something up that can give you as good performance monitoring as what you could get from a cloud provider currently.
- 48:21Okay.
- 48:22Wow.
- 48:22Yeah.
- 48:23You can ask for things like, what's the CPU percent on the system?
- 48:27And if you have like eight cores, it'll give you an array of eight floating point numbers that are percents.
- 48:32And you can say, what is the current process that I'm in?
- 48:34How much memory is it using?
- 48:35And things like that.
- 48:36It's great.
- 48:37Yeah.
- 48:37And you can access all the other processes as well.
- 48:40You can get similar information from all of them, from everything that's operating on your system.
- 48:44Yeah.
- 48:45Nice.
- 48:46So that was for watching processes and system stuff.
- 48:50Another thing that people often have to do is they have to watch a directory for when a file either changes or a new file arrives.
- 48:56Like somebody's uploaded some new CSV file.
- 48:59We've got to ingest it and do work on that.
- 49:01And you talked about a thing called a watchdog for that.
- 49:05Yeah.
- 49:05Have you used that before?
- 49:06I've not, but it sounds really cool.
- 49:08And like the others you brought up, it's very nice that it's cross-platform, even though that implementation is quite different on the different OSs.
- 49:15Yeah, that's right.
- 49:16And just like psutil, it abstracts away some fairly complex work into a very nice, very easy to use API.
- 49:23That is, again, cross-platform.
- 49:25One of my requirements for selection in the book throughout is that every library had to work in a fairly easy way on all the three big target platforms.
- 49:35So they should all be cross-platform.
- 49:38And watchdog probably does the best job of hiding platform differences away because these notification systems are quite different on each of the target platforms.
- 49:48And luckily, you don't have to worry about that whatsoever.
- 49:51It completely hides away those differences.
- 49:53And as you said, it gives you a way to monitor a particular directory for any changes.
- 49:57Yeah, it's really nice.
- 49:58So you just create a class driving from some built-in monitor event handler type of thing.
- 50:03And you say, call this function when you create one or call this one when a function is modified.
- 50:08And then you can just tell it to start observing.
- 50:11And it actually does that in the background on a background thread, right?
- 50:14Yeah, that's right.
- 50:14Yeah, very cool.
- 50:15So the other one you talked about, you alluded to before, is ptpython.
- 50:23Which I've not played with this, but I'm thinking this is getting installed.
- 50:26Because this is, I really don't love the REPL that much, the built-in one.
- 50:31But this is cool.
- 50:32I need to check this out.
- 50:33So tell us about it.
- 50:34Yeah, so ptpython is based on another Python library called Prompt Toolkit, which is a toolkit for making user interfaces in the shell or in a command line view.
- 50:45And ptpython is a replacement Python interpreter, but it's supercharged for editing and editing history and bringing back previous functions and changing them.
- 50:55And it has color support and a whole bunch of other features as well, which I could not get to in the discussion.
- 51:02I pretty much the first thing that I install after updating PEP and setup tools in a new virtual env is ptpython.
- 51:08And that's the interpreter that I use for doing any of that interactive kind of work.
- 51:12Yeah, it makes a ton of sense.
- 51:13Like, for example, if you, one of the things that drives me crazy in the REPL is I'll type out like a function or an if statement or a loop more likely.
- 51:22And then I'll either make a mistake or I want to run it again slightly differently.
- 51:27And then you've got to up arrow.
- 51:28Like, okay, I know I'm going to up arrow five times and hit enter and then like sort of unroll the history so I can get back.
- 51:35And then I got to remember the line I changed.
- 51:36And like this one, if you say, I want to go back to some multi-line thing I worked on,
- 51:40it actually pulls up the multi-line thing right there, which is already makes it worthwhile.
- 51:46Plus the color and the auto-completion and all that.
- 51:49That's great.
- 51:49Yeah, that's right.
- 51:50And so when you press up arrow and you get that multi-line statement that you did earlier,
- 51:53I use the VI key bindings.
- 51:56And that all works.
- 51:57I can go to the top of the line, go down.
- 51:58I can DD to delete a line or yank and paste.
- 52:02So if you're used to Emacs, they have Emacs key binding support.
- 52:05And if you're used to VI, you can enable VI key binding support.
- 52:08And you get the power or much of the power of those keystrokes and commands inside every single line that you edit and enter inside PtPython.
- 52:18Which is so much better than the built-in.
- 52:21Yeah, that's fantastic.
- 52:22If you run in a split screen in your terminal where you have, for example, your editor in the top half and a command line on the bottom half.
- 52:28If you run PtPython in the bottom half, what's really interesting is if the key bindings match the editor that you're using,
- 52:34you almost begin to feel like you're working in one environment because the key bindings work in your editor.
- 52:40And then when you jump to the REPL, it works there as well the same way.
- 52:43So that's really nice.
- 52:44I work like that almost continuously.
- 52:46Oh, that's really nice.
- 52:48Yeah, I like it.
- 52:49I'm definitely going to install it and check it out.
- 52:50The next thing is moving on to the web APIs and HTTP services and so on is something I had not heard of,
- 52:58but it's very nice.
- 53:00It's called Hug for building APIs.
- 53:02Yeah.
- 53:03So just like we discussed earlier with Begins, what I really, really liked about Hug is how they try to maximally exploit the features of Python
- 53:12to make as simple as possible use interface for you as a programmer to implement an API.
- 53:17I have had experience before with the Django REST framework, which is an awesome industrial strength, very well designed, very sturdy and robust REST framework.
- 53:28So I recommend that one strongly.
- 53:30Flask also has a good REST framework.
- 53:32Those are not bad choices at all.
- 53:33But I did have the impression that very few people knew about Hug.
- 53:37And for simpler kinds of applications, I think Hug makes it extremely easy to get a REST interface up.
- 53:43Yeah.
- 53:44And it's very service oriented, right?
- 53:47It's not looking like some web framework that also happens to allow machines to talk to it and return JSON.
- 53:56Like, for example, to take a function and make it a return JavaScript for get requests, you just say at Hug.get and you give it that decorator or a post or whatever, right?
- 54:08And you make it a API.
- 54:11Yeah, exactly.
- 54:12And you're done pretty much.
- 54:13And you get the documentation because it auto generates that from your function declarations.
- 54:17And versioning is also pretty easy to add, which I had in the later section.
- 54:22Yeah.
- 54:22So basically, if you make a request to the base URL for the host that's running the Hug service, it will actually describe all the services and how you talk to them and what's the inputs, the outputs, everything.
- 54:35And like you said, you can put versioning on it.
- 54:37So basically, you don't have to go and change everything about your methods and try to somehow bolt versioning on.
- 54:47You can just say in your decorator, this is for version two of the API.
- 54:51It also does argument conversion and stuff like that, right?
- 54:55That's right.
- 54:56Yeah.
- 54:56Nice.
- 54:56So, cool.
- 54:57It helps in the documentation, I guess, as well.
- 55:00If you say, here's an integer and its name is this, like the documentation can say, hey, it takes an integer called this.
- 55:04Nice.
- 55:05Yeah.
- 55:06Yeah, absolutely.
- 55:07Documentation, particularly for things like this, it's really a pain to write by hand.
- 55:12And no one should ever do that.
- 55:14Definitely, you want to use a tool that makes it really easy to produce documentation and to keep the documentation up to date.
- 55:20That's the key part, right?
- 55:21Keep it up to date because it's easy to create it and then just leave it.
- 55:25You know what?
- 55:26Well, I guess that changed.
- 55:28Yeah.
- 55:28Sorry, that documentation was wrong.
- 55:30Yeah.
- 55:30Nice.
- 55:32Okay.
- 55:32So, one of the things that's pretty challenging, I think, let me rephrase that, is more challenging than I think it should be, is working with dates in Python.
- 55:40And so, you have some cool libraries to work with that that you've found.
- 55:44That's right.
- 55:44So, the first option that I had there is not that unknown, I guess.
- 55:48Many people who have had to deal with dates and times have used Arrow for several years now.
- 55:53And the key thing about Arrow, or at least the key thing for me, I guess, is that it does away with this idea of having naive date times and so-called aware date times.
- 56:03Aware date times are date time objects that carry with them the time zone that they apply to.
- 56:08And naive date time objects do not have the time zone information attached.
- 56:13And, yeah, things get really out of hand if you start mixing and matching those without an awareness of what you're doing.
- 56:19And just by using Arrow, because it uses aware date time objects everywhere, simply by using Arrow, it means that you can avoid a certain class of problems where you're mixing up dates and times incorrectly.
- 56:31Yeah, and you run into weird problems.
- 56:32Like, if you try to subtract two date times, normally you get a time delta.
- 56:37But if one of them is time zone aware and one's not, then it will crash, right?
- 56:42So, no, you can't subtract these.
- 56:43Yeah, that's right.
- 56:45And worse is when you don't get crashes and you do arithmetic operations and the results that you're getting are not what you think you're getting.
- 56:52For example, in one part of your code base, you might call the now function.
- 56:56So, daytime.now, and then you get a time object.
- 56:59And in a different part of your code base, you call a very similarly named function called UTCnow.
- 57:04The problem is that the one gives you the time as it is in the UTC time zone, but without a time zone object attached.
- 57:12And the first one gives you the time as it is now, but in your local time zone.
- 57:15And the problem is that as a programmer, depending on the context of the code, you may perceive those two values to mean literally this moment in time right now.
- 57:24But the values are vastly different.
- 57:26They're obviously different by the extent of the times and differences.
- 57:29And so, when you do operations on them, you get very strange results.
- 57:32Or results that seem strange to you because of the assumptions you've made about what now actually means.
- 57:37Right.
- 57:38So, by using aware datetimes, you don't have those problems anymore.
- 57:41The time deltas that you obtain by doing operations between these are always correct.
- 57:45Yeah.
- 57:46So, even if one is from .now and others .utcnow, it knows to normalize those to some common time zone before it does math.
- 57:57Right?
- 57:58Like, if it wants to look how far apart they are, I would say, no, those are actually, you know, either the same or like one millisecond apart or something like that.
- 58:05Yeah, absolutely.
- 58:06Nice.
- 58:07So, that's coming from the universe into now.
- 58:10Into, you know, bringing in the time and working with it.
- 58:15The next library you talked about is about pulling time that's been saved already into a bunch of different formats and processing that.
- 58:22Because parsing time can be super challenging.
- 58:25I was talking on the previous episode with Anna Schneider.
- 58:28They were pulling together data sources from all these different utilities.
- 58:31And they said they have many, many different formats for time.
- 58:35That there are over 700 different formats for time out there.
- 58:38So, trying to just like deal with all that stuff is super painful.
- 58:41So, pars datetime, which is what you talked about, really actually does an amazing job of that.
- 58:47Even for human type stuff.
- 58:48Yeah, that's right.
- 58:49And this is another library that I discovered while doing the research for the book.
- 58:52I had not used this one before.
- 58:53I tried several libraries like this, but I was amazed.
- 58:56In the section of this book, I give some examples where parsed datetime is used to parse fairly typical looking datetime strings.
- 59:05But in the second half of the section, there's much more natural language type string sets that it also parses and does really well.
- 59:13I had a lot of fun doing the section because I tried to find ways of writing my statement of what day it was in very different ways, in very strange ways.
- 59:20And it seemed to get all of them.
- 59:22Right.
- 59:23Yeah.
- 59:24The last option that I had in my list was a string that said two weeks and three days in the future.
- 59:29And pass datetime correctly parsed that.
- 59:31I know.
- 59:32It's so amazing.
- 59:33Pretty amazing.
- 59:33Like when I had in mind of what would work, you know, you'll say, look, you can give it like 2016-07-16 or 7-16-2016.
- 59:43These types of things.
- 59:44And then I'll actually parse those all correctly.
- 59:46But then you started to get more interesting.
- 59:49And you said like yesterday, 10 minutes from now, three days ago.
- 59:53And it just totally got all this.
- 59:54And then you got to the most outrageous one, like you said.
- 59:56Two weeks and three days in the future.
- 59:58That's awesome.
- 59:59Yeah, it's pretty cool.
- 1:00:00I would really want to use this in an upcoming project.
- 1:00:03I just need to find the right project.
- 1:00:04Yeah, it's really good.
- 1:00:07I have my PyPI package and I'm looking for the project in which to use it.
- 1:00:10Exactly.
- 1:00:11And I think I confused Arrow with parsed at time.
- 1:00:15Arrow has the ability to give you like human relative time.
- 1:00:21So you can say on any arrow time, you can say humanize and it'll say just now, ask it again a little bit later.
- 1:00:27It'll say seconds ago or two hours ago or two hours in the future or something like that, which is really nice.
- 1:00:34Yeah, that's awesome.
- 1:00:35And the multilingual support is really good as well.
- 1:00:37I see that as being hugely valuable in web services and web development.
- 1:00:42No, I totally agree.
- 1:00:43Then the last part that you looked at, you said, okay, let's, these are all very purpose focused packages that we've talked about.
- 1:00:51Parsing date, time or scheduling something to recur every so often.
- 1:00:55But there's a couple of general purpose libraries that you talked about.
- 1:00:59And the first one, Boltons, is from a multi-time guest on the show, Mahmoud Hashabi.
- 1:01:05And he put that out there from the guys at PayPal, which was great.
- 1:01:09So you want to talk a little bit about what's good with Boltons?
- 1:01:11Yeah, for sure.
- 1:01:12The first thing, though, is that what's quite interesting to me, if you compare Python to some other languages,
- 1:01:17is because the standard library is so big and it covers a lot of ground,
- 1:01:22it's quite rare to find general purpose libraries in the Python ecosystem.
- 1:01:25I thought that was quite interesting.
- 1:01:27Boltons is one of the few ones that I did manage to find,
- 1:01:31where the intention is literally just to be a general purpose library for use in very, very different spheres.
- 1:01:37Most of the packages that you get on the package index are dedicated towards a singular purpose, usually,
- 1:01:43to perform some function, like all the other libraries that we've looked at.
- 1:01:47So I really thought that was interesting in doing the research,
- 1:01:49that there are not very many general purpose libraries.
- 1:01:52And my conclusion is that that must be because the standard library covers already most of the general purpose type of things that you need to do.
- 1:01:59I agree that that's probably true.
- 1:02:00I wonder if another reason, a secondary reason, is that it's pretty easy to bring in a bunch of small libraries.
- 1:02:09It's not like you've got to download and get the header files and the lib files and the right, you know,
- 1:02:14just statically linking and all that kind of stuff that you have to normally deal with.
- 1:02:17It's if you just pip install and import a bunch of stuff, you're good to go.
- 1:02:21So maybe it's also easier to have small libraries possibly.
- 1:02:25But yeah, I think you're right that because a lot of stuff is built in,
- 1:02:29a lot of people maybe put their energies towards fixing built-in stuff.
- 1:02:33And it's just, you know, it's a 25-year-old standard library, right?
- 1:02:36It's pretty polished at this point.
- 1:02:38I think you make a lot of sense.
- 1:02:39It also makes a nice parallel with the Node ecosystem where, similarly, there aren't too many general purpose libraries.
- 1:02:45And that's probably because it's so easy to bring in a lot of smaller libraries to make up the feature set you require.
- 1:02:50Yeah, absolutely.
- 1:02:52So maybe we could just really quickly touch on a few of the things.
- 1:02:54So one of the things that's in there that's pretty nice is the caching functionality.
- 1:02:59So you start out with cache utils.
- 1:03:01That's right.
- 1:03:02So the killer feature of the cache functionality in Boltons is the way that you can share a cache among multiple function calls.
- 1:03:09It's not that easy to do with the LRU cache that you get in the standard library.
- 1:03:13It's in the functools module.
- 1:03:16So you have to import functools.lrucache.
- 1:03:19The one that you get in Boltons is very easy to share amongst many different function calls as a decorator.
- 1:03:25That is the main attraction for me to use the cache in Boltons versus the one in the standard library.
- 1:03:29The LRI cache is also kind of interesting.
- 1:03:32I had to stretch a little bit to come up with an application to use both caches in the same code base.
- 1:03:38It's definitely good to keep an eye on the LRI cache.
- 1:03:42Yeah.
- 1:03:42Okay.
- 1:03:43And let's see.
- 1:03:44There was some other stuff that I thought was pretty interesting in there.
- 1:03:46One of them you had talked about was the at exit function, which I'd never used the at exit function.
- 1:03:51Yeah.
- 1:03:52The at exit function is pretty neat.
- 1:03:54You can basically set something up to run when it exits.
- 1:03:58Right.
- 1:03:58Yeah.
- 1:03:58So if you want to save some data structures and reload them at startup, you can just register these.
- 1:04:03Here's the shutdown functions to make sure you run.
- 1:04:05That's cool.
- 1:04:05Yeah, exactly.
- 1:04:06Another stuff that was in there that was nice was the iter tools that would give you like windowed chunked data.
- 1:04:12So for example, you talked about displaying that data interactively using PyQt graph.
- 1:04:20You could maybe combine that with the windowed iter tool.
- 1:04:23The iter tool is a windowed iter behavior and take some sort of stream of data and always show the last 50 pieces of the data,
- 1:04:30like in a few lines of code, right?
- 1:04:31Yeah, absolutely.
- 1:04:32For sure.
- 1:04:33The chunking and the chunked iter and the windowed iter, in my opinion, they're much better than the recipes that the standard library gives in its iter tools documentation,
- 1:04:41which I see as a fairly clunky way of piecing together building blocks from iter tools to get these same effects.
- 1:04:48I think it would make a pretty good addition to the standard library to have this chunked iter and windowed iter functions.
- 1:04:54Yeah, it's very possible that eventually some of these just become consumed into the standard library over time.
- 1:04:59It's great.
- 1:04:59You also have, there's also some nice debugging tools.
- 1:05:02That was cool.
- 1:05:04So you can say, yeah, PDB on signal, for example.
- 1:05:09How would you use that?
- 1:05:10Yeah, so you can attach this PDB on signal function inside your running application.
- 1:05:16And then by default, a keyboard interrupt handler will automatically be added to your program so that when a crash does occur,
- 1:05:23or when you, not a crash, but when you control C to stop your program, your program can stop at that point in a debug session.
- 1:05:30So for example, with a long running loop, if it's taking too long and you're wondering whether the program is doing the correct thing,
- 1:05:36or perhaps you suspect that it is no longer doing the correct thing,
- 1:05:40you can control C and you can get a debug prompt inside the loop wherever you sent the signal.
- 1:05:45Yeah, that's awesome.
- 1:05:46Just, that could be pretty handy in the right situation.
- 1:05:48Yeah, if you're wondering what the heck is this process doing?
- 1:05:50Is it stuck talking to the database, stuck talking to the web service?
- 1:05:54Is it just broken?
- 1:05:55Yeah, let's have a look, right?
- 1:05:57Yeah.
- 1:05:58Yeah, very nice.
- 1:05:59Okay, so let's, let's almost at the end so we should wrap it up.
- 1:06:03But the last major piece that you talk about in the general libraries is Cython.
- 1:06:07Yeah, so this 20 Libraries book actually came about as a follow on from an earlier video screencast series
- 1:06:15that I did for O'Reilly, which was on Cython.
- 1:06:17It's a huge five and a half hour long set of 75 videos covering how to get into Cython and how to start using it.
- 1:06:25That sounds great.
- 1:06:26I'll be sure to link to it from the show notes for everyone.
- 1:06:28Yeah, sure.
- 1:06:29I'll give you the link.
- 1:06:30And yeah, Cython, I think, has started now to gain some, some mindshare in the Python community, but not that many people are still using it yet, because it does introduce some things that are more complex than what you usually have to deal with in a Python package.
- 1:06:45For example, compiling with C extensions.
- 1:06:46However, Cython, among many other things, Cython can give the average Python programmer two key things that have, that have long been desired.
- 1:06:57The first one is Cython can speed up hotspots inside your source code easily affect a hundred or more if we're talking about basic math computation.
- 1:07:06A hundred times is not something to take lightly.
- 1:07:09It's the difference between, you know, running for a hundred days or running for one day for a very big long running process.
- 1:07:15And the second thing that Cython can give you, again, for the right kind of situation, which might be mathematical computation, is an easy way to run your threads on different CPUs without the global interpreter lock interfering in any way whatsoever.
- 1:07:28Something that I tweeted just yesterday was, there seems to be a misconception in some circles that you need OpenMP support to use parallelization in Cython.
- 1:07:36And that's not the case.
- 1:07:38You can get pretty good parallelization just with normal Python threads, as long as inside your Cython functions where you want to enable that, you release the GIL.
- 1:07:46Right.
- 1:07:46And there's a way you can even do that with context managers, right?
- 1:07:49You can say with no GIL or something like that, right?
- 1:07:51That's exactly right.
- 1:07:52Yeah.
- 1:07:52So for me as a Python programmer now in the situation that I'm in, the GIL is not really that big a problem for me.
- 1:07:59It depends on the details of the situation.
- 1:08:02But for heavy math computation, where I want to be able to access all the cores, and I simultaneously want my code to run faster than it normally might just with a plain CPython interpreter, Cython gives me both of those things in the same package.
- 1:08:14It sounds really great.
- 1:08:15I've not had a chance to do enough scientific work, but I can see it even being useful outside of scientific computational stuff.
- 1:08:24For example, if you're writing, let's just say I'm writing some kind of ORM or something, and I'm spending a ton of time taking objects off the stream and the data layer and actually turning those into objects.
- 1:08:37And just that processing there is like some big hotspot if I do a query that returns 100,000 records.
- 1:08:43Maybe that loop could be written in Cython.
- 1:08:46Is that right?
- 1:08:47Yeah, absolutely.
- 1:08:47So a good example is something that I've been doing at work for the past week, which is converting our protocol buffer code away from using Google's protocol buffer implementation to using a new tool called Pyrobuff.
- 1:08:59Pyrobuff is itself written in Cython, and it generates a pyx file for you to use as your object implementation of the protocol buffer rather than just using your normal Python-based implementation of the protocol buffer.
- 1:09:12I'm not going to go into what the protocol buffers are, but basically it's exactly what you were saying, object serialization that you shuffle between two places.
- 1:09:19And Cython has been used to create the protocol buffer using Pyrobuff.
- 1:09:23But in addition to that, I use the object, the particular object that that process generates inside another Cython file, which I can then use directly with no overhead from the Python interpreter.
- 1:09:32Yeah, that's great.
- 1:09:33That's really cool.
- 1:09:34All right.
- 1:09:35So you've definitely given me a broader view of where Cython is applicable, and that's cool.
- 1:09:40So let's round it out with one final awesome thing that you point out.
- 1:09:45And that's a GitHub repository or project that is just a huge collection of stuff like this that people have found awesome.
- 1:09:55Like here's all the awesome Python packages for OCR.
- 1:09:58Here's the awesome ones for e-commerce and so on.
- 1:10:01And that's awesome Python on GitHub.
- 1:10:02Yeah.
- 1:10:03Awesome Python is so awesome that many of the other language communities have now begun to copy it.
- 1:10:08So you can also find awesome Go and awesome Ruby and many of the other variations.
- 1:10:15Very cool.
- 1:10:16Very cool.
- 1:10:17So, Kayla, this has been really interesting.
- 1:10:20I learned a lot from your book and not necessarily many of the pieces that we talked about, but maybe even the ones that we didn't get a chance to cover.
- 1:10:30There's a bunch of other interesting packages that we're using in conjunction with your demos that I'll leave it just vague.
- 1:10:38And people can go check out the book, which at least a little while ago you could get as a free e-book from O'Reilly.
- 1:10:44I'll link to it.
- 1:10:45But highly recommended.
- 1:10:46I think it was time well spent to go through it.
- 1:10:49So thanks.
- 1:10:50Okay.
- 1:10:50Yeah, my pleasure.
- 1:10:51Yeah.
- 1:10:51So let me ask you, as I always do everyone, but it's a bit of a bigger list to pick from.
- 1:10:58What's your favorite PyPI package?
- 1:11:00If you have one out of all the books that you would say, like, okay, this is the thing people should take away if they're not going to get the book.
- 1:11:06My pick for the PyPI package is pretty much anything inside the Bware project.
- 1:11:11I very strongly feel that the contributions that Russell is making are very positive for the Python community and they're forward looking.
- 1:11:18The things that he's working on in the Bware project are things that we need to have happen in our community and our space.
- 1:11:24So for anyone who's thinking about finding a project online that they want to contribute to, maybe get a little bit of experience, that is a great place to go.
- 1:11:32There's the Togo framework, which is intended to be used as a way of writing platform-native graphical user applications in Python.
- 1:11:40But there are a whole bunch of other smaller projects that you can adopt and get into and dive in and play with the details.
- 1:11:45There are projects for running Python on iOS, projects for running Python on Android, and a bunch of different other features.
- 1:11:52He also has a project for packaging up Python for deployment to target machines, which is another issue that many people in Python feel has been, I guess, under-addressed.
- 1:12:01The issue of deployment.
- 1:12:02Yeah, I definitely think it's under-addressed for desktop spaces, absolutely.
- 1:12:06Absolutely.
- 1:12:07For sure.
- 1:12:07Or mobile, for that matter.
- 1:12:09But anywhere but the web or just your shell, I guess.
- 1:12:12Yeah.
- 1:12:13Yeah, okay, very cool.
- 1:12:14That's great.
- 1:12:15Check that one out.
- 1:12:15So, Beware.
- 1:12:16The name of the project is Beware.
- 1:12:18If you're looking for something to work on, you could do much worse than that project.
- 1:12:22If you're writing some code, what editor do you use?
- 1:12:23Yeah, that's a great question.
- 1:12:24So, I've been doing this a while now.
- 1:12:26And for most of those years, I've been using Vim.
- 1:12:28And since January, I've started using PyCharm because the scales have tipped the balance for me.
- 1:12:35And the features that PyCharm now provides outweigh what I can do to the best of my knowledge with Vim configuration.
- 1:12:42So, yeah, I'm now writing my Python code in PyCharm.
- 1:12:45All right.
- 1:12:46You and me both.
- 1:12:47I love that one as well.
- 1:12:48That's great.
- 1:12:48Yep.
- 1:12:49All right.
- 1:12:49Final call to action for listeners out there.
- 1:12:52First of all, check out the Beware project and contribute to that if you're looking to write some code.
- 1:12:56Anything else?
- 1:12:57Get your book.
- 1:12:57Where do they get it?
- 1:12:58Oh, you can get the book at O'Reilly.
- 1:12:59I think if you search for 20 Python libraries you aren't using, that should be enough.
- 1:13:02Google will find it for you.
- 1:13:04And of course, then there's my Cython course as well.
- 1:13:06If you do want to get more into Cython, you can check out my course.
- 1:13:09As far as I know, I think it's the only video course currently available for Cython.
- 1:13:13But I might be wrong about that.
- 1:13:15But that's something else to check out.
- 1:13:16And then maybe the last thing I would mention is just as a general comment, sometimes you see on forums like Reddit and other places, there's a lot of dissatisfaction with some of the decisions that the core Python development team make regarding certain features in the language and what gets included and what gets excluded and so on.
- 1:13:32And I would encourage people to follow the newsletters and the mailing lists to see a bit more about the discussions that go into these decisions.
- 1:13:40The core team has many, many difficult and complex issues to deal with regarding the features that they include or exclude.
- 1:13:46And before I started the mailing list for Python Dev, I had the same thoughts about, you know, why was this designed that way?
- 1:13:52Why didn't they include that?
- 1:13:53Why is that not done?
- 1:13:53But once you begin to follow the mailing list and you start to see the discussions and the complexities that they have to deal with, for example, in the pip project, that's another good example.
- 1:14:01Once you begin to see the complexities that these teams are dealing with, you begin to understand why the decisions get made in the way that they do.
- 1:14:07So I just want to make a point there that if anyone feels dissatisfied with what the core Python team has been doing, get involved and find out more about why the decisions are getting made in particular ways.
- 1:14:18Yeah, I think that's great advice.
- 1:14:19Certainly looking at how the trade-offs are being chosen is definitely important.
- 1:14:24Thank you so much for sharing your book and all this research you did.
- 1:14:28It's really helpful.
- 1:14:29Sure, my pleasure.
- 1:14:30I think people should, they should check out the book.
- 1:14:32They'll definitely enjoy it.
- 1:14:32Thanks for being on the show.
- 1:14:34Yeah, thanks, Michael.
- 1:14:35Great.
- 1:14:35You bet.
- 1:14:35Bye.
- 1:14:35Okay, bye.
- 1:14:36This has been another episode of Talk Python To Me.
- 1:14:41Today's guest has been Caleb Hadding.
- 1:14:43And this episode has been sponsored by Capital One and Intel.
- 1:14:47Thank you both for supporting the show.
- 1:14:48Are you a data scientist or Python developer who loves data?
- 1:14:53If you're looking for a place to work on data science with truly big data that can affect millions of lives, then head on over to jobs.capitalone.com.com.
- 1:15:01And check out the wide range of jobs that Capital One is trying to fill right now.
- 1:15:07The Intel distribution for Python delivers the high-performance Intel C libraries built right into Python.
- 1:15:13Get close to 100 times better performance for certain functions when using NumPy, SciPy, and scikit-learn.
- 1:15:19Check them out at talkpython.fm/Intel.
- 1:15:22Are you or a colleague trying to learn Python?
- 1:15:25Have you tried books and videos that just left you bored by covering topics point by point?
- 1:15:30Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course to experience a more engaging way to learn Python.
- 1:15:39And if you're looking for something a little more advanced, try my Write Pythonic Code course at talkpython.fm/pythonic.
- 1:15:46You'll find the show notes and links from this episode at talkpython.fm/episode slash show slash 77.
- 1:15:53Be sure to subscribe to the show.
- 1:15:56Open your favorite podcatcher and search for Python.
- 1:15:58We should be right at the top.
- 1:15:59You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 1:16:09Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
- 1:16:14Corey just recently started selling his tracks on iTunes, so I recommend you check it out at talkpython.fm/music.
- 1:16:20You can browse his tracks he has for sale on iTunes and listen to the full-length version of the theme song.
- 1:16:26This is your host, Michael Kennedy.
- 1:16:28Thanks so much for listening.
- 1:16:29I really appreciate it.
- 1:16:30Smix, let's get out of here.
- 1:16:32Stay tuned.
- 1:16:54Don't put it on the ground.
- 1:16:55Thank you.