Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 140, recorded July 18th, 2019. I'm Michael Kennedy.
And I'm Brian Ecken.
And this episode is brought to you by DigitalOcean. Check them out at pythonbytes.fm/DigitalOcean.
More on that later. Brian, how you been?
I'm doing great.
Yeah, wonderful.
You?
Yeah, very good. I just got back from a camping trip in Astoria, right on the coast there.
And it's nice to get away from the computers for a couple days.
Yeah.
But it's good to be back.
So the Python news, it has been flowing even while I was gone. So that's pretty awesome.
Let's get started with your first item. What do you got here?
Well, people have been... I'm not going to get into the 10x controversy too much, but there's some 10x developer rubbish going around Twitter recently.
I think partly for clickbait, but I'm not going to hold it against her.
Kate Heddleson put together a article called Becoming a 10x Developer, 10 Ways to Be a Better Teammate.
And I read it, and that's actually a lot of great advice.
So a quote from her is, a 10x engineer isn't someone who is 10 times better than those around them, but someone who makes those around them 10 times better.
Which is humbling because I don't think I do that.
I try, but you know.
Do you feel like that's not properly rewarded?
Like in business and projects and stuff, like what gets measured gets optimized, right?
And if you're in an organization where they don't take that as a major factor into like how you're doing, like, well, what features did you ship?
Like what things did you work on?
And so on.
If your job is to kind of float around and make sure everyone is like not hung up on how to use this API or they don't know this backstory on how to use this thing or why it is the way it is.
Like if you spend too much time doing that, are you like hurting your career?
I think it probably definitely depends on the organization and probably even within a company, it changes based on like what division or what group you're in or something.
Yeah.
And I've certainly seen places where it's highly valued and it's like recognized and other places where it's like, well, but what have you been doing?
You know, it's not the best.
Well, I mean, there definitely has to be a balance.
You can't just be a cheerleader and a coach.
We actually do need to get stuff done also.
And actually, I'm amused that it's a weird controversy now that to say like that there's the 10x is 10 times better than average.
And I don't think it ever started out that way.
I think it started out just with acknowledgement that there's orders of magnitude between the productivity of the most productive people and the least productive people.
And I don't think that that's controversial.
No, it's definitely not.
Whether or not you believe in the 10x thing, these are great advice.
So I'm just going to run through them.
Number one, create an environment of psychological safety.
And there's a reference to a Google study basically saying people are better creative work if they feel safe in their environment.
So number two, encourage everyone to participate equally.
Three, assign credit accurately and generously.
Four, amplified unheard voices in meetings.
I love that.
Five, give constructive, actionable feedback and avoid personal criticisms.
Six, hold yourself and others accountable.
Seven, cultivate excellence in an area that is valuable to your team.
Eight, educate yourself about diversity, inclusivity and equality in the workplace.
Nine, maintain a growth mindset.
And last, advocate for company policies that increase workplace equality.
I don't think there's anything to argue about, but this is good stuff.
Yeah, these are all great things to keep in mind.
And Kate's definitely been a voice for these types of things for a long time.
So it's good to see her put it in the context of this 10x story.
And I encourage people to read the article because every one of these, if you're like, I don't know how to do that.
She gives actionable advice on what you can do to increase any of these.
So it's good.
Yeah.
Cool.
This next one that I want to talk about here is interesting.
It's a little bit more JavaScript-y than the stuff that we normally cover.
Normally, it's like pure Python.
But I feel like there's enough tie-ins together here.
So this one comes partially to us from Doug Farrell, who's done some cool articles over at RealPython.
He's been on the show before and things like that.
So the first thing that he sent over is this new framework called Quasar.
And Quasar builds on top of Vue.js, right?
Now, if you're going to build some kind of front-end JavaScript thing, you know, maybe it's going to talk to Python on the back-end, a bunch of APIs you're going to write.
But it's going to be mostly JavaScript and front-end stuff.
Well, Vue.js, in my opinion, is really one of the best choices, right?
It's simple.
It's easy to get started with.
It works really, really well.
It's not as complicated or convoluted as, like, AngularJS or something like this.
So Quasar, what it does is it builds on top of Vue.js, adding all sorts of cool components that you can use.
And it lets you create many different types of apps.
You can create a single-page application that is, like, an app that loads.
You never really navigate away.
It's constantly, like, updating itself through JavaScript.
A server-side rendered app, which is cool.
Progressive web app, which is cool.
But then you can also do mobile apps, Android and iOS.
That's cool.
And multi-platform desktop apps using Electron, like Visual Studio Code or Slack or whatever.
All of that with the same code base based on Vue.
That's cool.
That's pretty cool, right?
So if you could build that, that's great.
And, of course, Python on the back end is, like, obviously a super, super good choice.
I mean, that's how it is for my mobile apps, but Xamarin on the front end.
But, like I said, it's great.
There's tons of these things you can just drop in and get cool little widgets and progress bars and buttons and, you know, all the kind of things you need to build your UI.
But what if it could be all Python?
What if the stuff that you write on the front end or the server-side rendered bits, what if that could also be Python?
That would be nice, right?
Yeah.
What I mean is to not write JavaScript in the browser, but instead write Python.
And you might think, silly.
No way.
But there's this thing called Vue.py.
And Vue.py provides all the bindings for Vue.js, runs on Brython, which is a way to put Python in the browser.
And there's a bunch of cool example apps that are non-trivial that you can work with.
So you just write pure Python code.
If you want to create, like, a Vue.js component, you just derive from the component class in the Vue.py thing.
And it's just pure Python.
Wow.
That's pretty cool.
So there's some examples right at the bottom.
And you can pull those up and you can run it and so on.
So my favorite one is this thing called the SVG graph.
So they all have, like, a demo and they have the source.
And you can run it.
And the first time, it takes them, you know, maybe a couple seconds to download the Brython JavaScript and whatnot.
But it's like a super cool little interactive little thing all in Python.
You can check out the source.
Neat.
Yeah, definitely will.
That's cool.
Yeah.
So I was a little hesitant to cover Quasar because it's pure JavaScript.
But if I can take Vue.py and then write this, then now we're talking.
Now we're getting somewhere interesting.
Now build on top of that that the Electron apps don't care about how much download time it takes or whatever, right?
Because you ship it.
Like, one of the things included with a Vue.js, sorry, an Electron app is Chrome, right?
Which is like 60 megs or more.
So, you know, who cares if you throw in an extra 200K for, like, Brython JavaScript.
So it could be a really cool way to build some desktop apps with Python and Vue.js.
Yeah, I think that's a neat idea.
Cool.
Yeah.
Anyway, it's kind of a cool mix of front-end JavaScript and some Python, maybe even in the front-end.
Yeah.
Yeah, all right.
What's the next one?
Well, in episode 138, we talked about regular expressions a little bit.
And I made a joke on Twitter about regular expressions.
And then I got a whole bunch of people, like, giving me resources back.
And there's a couple of them that I'm actually really excited about.
So the first one I want to cover is a website called Regular Expressions 101.
It's at regex101.com.
And I kind of wish I had this a long time ago.
Because I know regular expressions are a little different in different languages.
And this one, you can select Python or PHP or JavaScript or Go as the one you're working with.
And then you can just start typing in a regular expression example.
Or you put in, like, an example string that you want to match.
Maybe even some stuff you don't want to match.
But then as you're typing the regular expression, it shows you and highlights the different areas where it's
matching, where it's not matching.
And then since we also have match groups and multiple matches, it shows you how that works, too.
And there's also, like, a little quick reference guide.
It's actually mostly what you need.
Like, for instance, I forgot the...
I always forget how to do, like, if I want to match a character, but I want to match, like, one to three characters of that type, not just more than one.
I mean, I remember that star is nothing or all and plus is one or more.
But what about if I want to match, like, three?
How do I do that?
Yeah.
I always forget that.
So, that's there.
And so, if you have to generate...
As you're generating them, I think this is a pretty cool tool.
I'm going to use this more.
Man, I got to say, this is really slick.
I love it.
You can select it, like you said.
You select the different language types.
And it will even give you, like, assistance on what it means, right?
So, I typed dot plus and it says, oh, the dot plus matches any character except for line terminators.
The plus matches one and unlimited times.
And then I wrote a little capture group and it says, oh, the capture group means this and whatnot.
And yeah.
Oh, so, like, if you're looking at somebody else's code, for instance, and there's a regular expression you don't understand,
you could pop it in here and it could, like, explain to you what it all means.
Yeah.
It's, I got to say.
Cool.
And then if you want to see it running in action and in your code, you can hit the generate function
and it generates a little script for you that you can just copy and paste into a file and run it to see what it looks like.
It's pretty nice.
Yeah.
This is a super slick little web app.
If I was better at regular expressions, I would be able to do really cool stuff, but I can just kind of.
Kind of write them.
So, it works still.
It's good.
And then somebody else mentioned RegX Golf.
And it's just, it doesn't teach you at all.
It just has two lists of strings and you're supposed to match the first list and not the second list with a regular expression
and try to do it with the least amount of characters.
So, possibly not.
Well, I mean, you can do it with as many characters of regular expression as you want, but some of them, people have matched it with one character.
And I'm like, how?
How did you match it with one character?
Yeah.
That's pretty awesome.
And got some spare time, I guess.
Well, you know, I'm a manager and all, so the spare time comes with the territory.
That's right.
Now, this regular expression 101 is a super cool web app, and I'm definitely going to save it.
Anytime I got to do regular expression stuff, I'm going to go back to it.
Speaking of regular, tell me about our sponsor today.
Yes, our regular sponsor, DigitalOcean.
They've been sponsoring the show for quite a while, and they're doing all sorts of cool stuff.
They got managed Postgres database services.
Obviously, their main thing is running virtual machines, and really quick and easy to do that.
I was just logged into a bunch of mine there today to upgrade some stuff.
And they also have now a Kubernetes cluster option.
So, they've managed Kubernetes services.
It's super easy to go over there.
In just a few minutes, you can have your Kubernetes cluster up and running, and they take care of all the stuff you need for that.
So, if you're thinking about doing anything with Docker and scaling it out, check out Kubernetes, of course,
and then the Kubernetes service over at DigitalOcean.
Very, very nice.
And, yeah, they're great supporters of the show.
A lot of our infrastructure runs on what they're doing.
So, appreciate that and can definitely recommend them.
Try them at pythonby.sad.fm slash DigitalOcean.
Get a $50 credit for new users.
Now, places like DigitalOcean and many of the other hosting spots that you might go and use, they're now offering SSD solid-state drives as basically a default option.
So, you get really fast disk access, right?
Yeah.
Yeah, well, if you have fast disk access and you can speak properly, you could actually use that as a cache, right?
So, caching has huge benefits for making our apps faster.
And a lot of the ways that people think about caching is they think about, I'm going to pre-compute some stuff and cram it into memory.
Oh, yeah.
And that's okay.
But, like, so, if you go over to, say, DigitalOcean and you fire up a server, the server comes with one gig of memory, but 25 or 50 gigs of SSD, right?
So, if you're trying to squeeze a lot of performance out of your app, you could go buy, like, a super high memory version, or you could set up a separate server that's doing Redis or something like that, which still is also going to kind of run into that issue.
Or you could just use that really fast disk.
So, this next, the fourth item I want to talk about is something called Python-DiskCache.
I'm not going to give it a huge grade for creative naming, but definitely descriptive.
Yeah.
So, the idea is that we can basically treat this Python-DiskCache kind of like Redis.
Like, you put an item, you get an item, but it stores it on disk.
And it's apparently super fast.
And it's also pure Python.
I don't get it.
If it came from disk and you're caching it on disk, for data that…
It might not have come from disk.
What if you call, like, a search API or you…
Oh, yeah.
You're using somebody else.
Right.
Somebody types in, I want to find X on the website.
And you have to go to, like, do a big complex database query or an elastic search query.
Okay.
Got it.
Okay.
Instead, you could say, this key of search for this goes to, bam, those results.
And now you just, like, deserialize them, like, pickle or JSON or whatever.
And it's just, like, super, super quick.
Oh, okay.
Yeah.
Nice.
Or even if you're doing, like, computational stuff.
Like, I know if I pass in 20 to this crazy computational method, I get this number back.
Right?
Well, you can cache that.
Right?
And you can cache it in memory.
Right?
That's okay.
Like, you can use the functools LRU cache, which is pretty cool.
But even if you have enough space, it doesn't keep working across, like, reruns of your app.
So, you run it once and it does some stuff.
But then as soon as it exits, it's gone from memory.
Right?
Then you run it again.
Well, now it's got to start over.
But if it's on disk, it's persistent.
Right?
So, that's cool, too.
Yeah.
Django itself has built-in caching, which is cool.
But apparently, at least according to the author of this, I don't do enough Django to know for sure.
But apparently, the file-based cache in Django is essentially broken.
If you listen to what he says.
So, let me pull up the little section where he says that a calling method is random and large caches.
Repeatedly scan cache dictionary, which is slow.
You know, it could take, like, 60 milliseconds to store a key with a couple thousand items in the cache.
Like, that's kind of ridiculous.
So, apparently, this thing, this disk cache, is much, much faster.
And it takes microseconds, not milliseconds, which is pretty awesome.
And it's a built-in pluggable replacement for the Django cache.
You could just say, Django, use this thing as the disk cache.
Oh, okay.
Nice.
Yeah.
It basically uses memory map files and other database technologies to store stuff on disk, which is pretty cool.
It's all C.
Sorry.
It's no C.
It's all Python, which is great.
You'd like this.
It has 100% test coverage with unit tests and hours of stress tests.
Yeah.
And pytest.
Yeah.
And finally, you might say, well, I've heard of other things like this, right?
Like, there's other types of caches like this.
So, there's stuff called DBM and Shelf and SQL dict and PickleDB.
And I think these are all new to me.
But there's a bunch of these other similar types of things.
But what's cool is they have, like, a really great breakdown of all the features you might care about.
Like, for DBM, is it Atomic?
For Shelf?
Is it ThreadSafe?
And so, it really shows you a lot of places why you might care about using this in addition to just, oh, here's yet another.
Right.
I like the comparison.
Looking at that table, it looks like disk cache is based on, or it stores the data in SQLite.
And we know SQLite's really fast, so.
Yeah.
You already get indexes for efficient lookups and inserts and stuff like that.
Yeah.
So, cool.
Very, very cool.
So, if you have to cache stuff or you have things that are slow in caching MyFixit, this is actually a really interesting way to think about it.
Because the alternative of setting up other servers like Redis and then having to manage the connections and all that, like, that's great if that's something that works where you need it.
But, like, this seems really simple.
Yeah, and I was thinking along the lines of companies that store or are keeping track, like, for dashboards and stuff, they're pulling data from various places.
But it's – and people can look back in old stuff, but it's mostly the recent things that people are looking at all the time.
And so, something that caches the more recent stuff makes a lot of sense.
Yeah.
And it's quite cool.
Yep.
What's the next one?
Oh, yeah.
It's my turn.
Speaking of – I was just looking at the disk cache stuff and they were talking about how to learn more you can use the help system.
Yeah, it's like the tutorial is type help this, type help that.
Yeah.
And so, that's what I want to talk about.
I want to talk about the Python help system.
And I guess I knew it was around, but I kind of forgot.
So, there was an article on Stack Abuse about the Python help system.
And in a Python REPL, you can, like, for instance, type help print.
And then you do, you know, help as a function.
And you pass it.
If you pass an object or a built-in something, like print and dict or built-ins, you get, like, a lot of information.
Like, if you type help dict, you get basically a tutorial on what all the stuff you get on dictionaries.
It's pretty nice.
And I tried, like, in things that are keywords that are not objects, you can type help on those, too, but you put them in, like, quotes first.
So, like, you can type help, quote, assert, and get all the information on how assert works in Python.
And you can import stuff so it's not just the built-ins.
You can, like, for instance, one of the examples was import math and then help on math.log.
And, yeah, you can learn about log.
Like, I just did that to try it.
And I'm like, oh, cool.
I always forget that log can take a different base.
So, you can do, I don't know, base 7 if you were just crazy and wanted to.
And then for non-built-in stuff and other libraries, even your own stuff, help will pull out the doc string.
And, I mean, there's actually, I forget about this.
There's a lot of stuff that you just type help on that instead of Googling or hitting Stack Overflow, you just look it up.
Yeah, and it's right there.
And it even works with it.
It's offline.
It's great.
You're right that help dict has a ridiculous amount of stuff in there.
That's pretty crazy.
I've never typed that.
Shows you all the magic methods that are overridden and all the stuff that happens.
Yeah, it's quite cool, actually.
Yeah, and the things that you can convert to dictionaries and, yeah.
Yeah, it's a nice one.
Keeping with the same line of thinking of, like, I have some code and I want to understand, like, how it works and how it fits together, right?
This is, like, the documentation and some of the methods and examples and stuff.
But David said and sent over a cool couple of projects that he works on that is, like, a higher level architectural overview of Python libraries.
So, I think these are created by him.
And one is called impulse and one is called import linter.
And the idea is that you get a quick picture of all the dependencies within a Python package.
Oh, nice.
Yeah, so I could type impulse space draw graph space and then some Python package that's installed in the same environment as the impulse thing is.
So, it can find it.
And then it'll go and, like, look all through it and say, well, here's all the modules, submodules, classes, and so on that are referencing each other.
And it draws, like, a cool architectural graph of, like, this depends on that, which depends on that, and so on.
Oh, wow.
Yeah.
So, it's a good idea to just run that against code that you're not super familiar with.
So, like, before you go digging through the source code, like, let me just get a picture of what's in here and what's talking to what, you know?
Yeah, and also, if people keep asking about a particular part of your code base, do this and see how many loops and knots are in it.
And maybe that's why.
Yeah, exactly.
Like, oh, it's a little more complicated than it probably should be, or why does everything depend on this?
Yeah, it's cool.
If you want to run it, you might get an error that it can't draw the graph.
You have to have GraphViz separately installed because it draws the graph and then it hands it, like, the data off to there to do the drawing.
And if you're on a Mac, you can just brew install GraphViz, you know, just basically have that installed, and then you can more or less just run impulse draw graph on things.
It's great.
Nice.
Yeah, the other one, ImportLenter, allows you to check contracts about the dependency graph.
So you can say, like, we want to prevent circular dependencies or other types of constraints.
Like, this should never depend upon that.
So you can run it, and it's like part of a continuous integration, and it'll tell you if, like, some rule you said this shouldn't happen, you know, it changes in terms of dependencies.
Oh, interesting.
Yep.
Yeah, this is cool.
Yeah, I think I would definitely use impulse, the graph one, more than the linter, but I can see, like, depending on what you're doing, like, one might be more valuable than the other.
Yeah, I mean, if you were teaching a class and you said, I want you to implement something, but don't use package X.
That's right.
You could just have this as a test.
Submit your answer here, and we'll lint it.
Yeah, it's cool.
Yeah.
So if you care about these architectural graphs and whatnot, yeah, these are nice tools.
You can turn on your Python code.
Yeah, nice.
Well, so that's all of our six.
Do you got anything extra for us?
I ran across something that I'm sure some folks know about, definitely the core developers know about, but I just, you know, it just made me laugh.
I was just like, all right, this is funny.
So I was working on some package, and I needed to understand it better, so I used PyCharm, go to definition, and took me inside the source code of some part of the standard library, and I saw it was importing TabNanny.
I'm like, what the heck?
TabNanny.
So TabNanny, as in like the babysitter of tabs or something, I don't know, is apparently a standard module, and it checks for inconsistent mixtures of tabs and spaces.
And I knew Python checked it.
I just didn't know that the thing that did that checking was called TabNanny.
So I thought that was funny.
I thought I'd share that with you all.
That's awesome.
And there's a thing called BadTabs.
Yeah, it's pretty funny.
Yeah, nice.
Yeah, so I guess one other thing, quick shout out, just to let people know that the Flask Data Driven Web App course is out, and people can give that a check out.
It seems like everyone's enjoying that.
So if you want to work with Flask, that's also a good one.
Okay.
Anything for you, Brian?
Nope.
Just working away.
The new office is working pretty good, but I've decided, like, last week I was sitting on the ground.
I've got a chair this week, so this is good.
You're upgrading your podcasting studio from the office, I see.
I'm elevating my environment.
Yeah.
Nice.
All right.
We have two jokes for you all this time.
You want me to kick this one off?
Yeah.
All right.
This is a joke that never gets boring.
Okay.
You can tell it as many times as you want.
It's never the same.
All right.
So two threads walk into a bar.
The bartender looks up and yells, hey, I don't any conditions race-like time last want.
Yeah.
The next time you tell it, you could be like, hey, two threads walk into a bar.
A barkeeper looks up and yells, don't any conditions I, hey, want race-like time last.
Right?
Just it's good every time.
Yeah.
It's good every time.
All right.
How about you?
A string value walks into a bar and then was sent to standard out.
I love it.
Pipe joke.
That's great.
Always good to finish on a laugh.
Brian, thanks for being here and doing all this research for everyone.
Yeah.
Thank you.
Yep.
You bet.
See ya.
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.