Python Bytes - #140 Becoming a 10x Developer (sorta)
Episode Date: July 23, 2019Topics covered in this episode: Becoming a 10x Developer: 10 ways to be a better teammate quasar & vue.py Regular Expressions 101 python-diskcache The Python Help System Python Architecture Gra...phs Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/140
Transcript
Discussion (0)
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 slash 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 an 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 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 and 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. If you spend too much time doing that, are you hurting your career?
I think it probably definitely depends on the organization.
And probably even within a company, it changes based on 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 recognized
and other places where it's like, well, but what have you been doing you know it's not the best well there 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 that 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.
Number two, encourage everyone to participate equally.
Three, assign credit accurately and generously.
Four, amplified unheard voices in meetings. I love that. Five, give 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 to next 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 JavaScripty 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 view 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 bunch of apis you're
going to write but it's going to be mostly javascript in front and stuff well view 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 navigate away it just is 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 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 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 view.py. And view.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, it's 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 it's, 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 of seconds to download the,
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.
Well, that's cool.
Yeah.
So I was a little hesitant to cover a quasar because it's pure JavaScript,
but if I can take view.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 who cares if you throw in an extra 200K for like a Brython JavaScript?
So it could be a really cool way to build some desktop apps with Python and VJS.
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.
In 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?
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 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, yeah, it's, I gotta 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'd be able to do really cool stuff, but I can just kind of write them.
So it works still.
It's good.
And then somebody else mentioned RegEx Golf.
And it just 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 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.
And anytime I've 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 a sponsor of the show for quite a while, and they're doing all sorts of cool stuff.
They've got managed Postgres database services.
Obviously, their main thing is running virtual machines 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.fm slash DigitalO, get a $50 credit for new users. Now places like digital
ocean 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, right? 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 and that's okay but like so if you go over to say digital ocean 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 by 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 dash disk cache.
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 disk cache 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.
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.
So, 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? 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.
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 combing 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 can 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 like this. 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 Shelve and SQLDict 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 Shelve, is it thread safe?
And so on. 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 and caching might fix it,
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,
that's great if that's something that works where you need it.
But this seems really simple.
Yeah, and I was thinking along the lines of companies that store or are keeping track
for dashboards and stuff.
They're pulling data from various places,
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 quite cool. Yep. What's the next one? Oh yeah. It's my turn.
I was 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 is 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 and 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.
I mean, there's actually, I forget about
this, there's a lot of stuff that you could just type help
on that instead of googling or
hitting stack overflow, you just
look it up. Yeah yeah and it's right
there and even works with it's offline it's great you're right that help dict has a ridiculous
amount of stuff in there that's 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 Yeah, and the things that you can convert to dictionaries. Yeah, it's a nice one.
Keeping with the same line of thinking of like,
I have some code and I want to understand how it works and how it fits together.
This is like the documentation and some of the methods and examples and stuff.
But David Seddon 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 sub modules 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, let me just get a picture of what's in here and what's talking to what.
Yeah.
And also, if people keep asking you 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.
It's a little more complicated than it probably should be.
Or why does everything depend on this? Yeah, it's why. Yeah, exactly. 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 off, 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 import linter 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 that's just 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 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.
So if you care about these architectural graphs and whatnot, yeah, these are nice tools.
You can turn on your Python code.
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 just 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 tab nanny.
I'm like, what the heck? Tab nanny.
So tab nanny is in like the babysitter of tabs or something. I don't know. It's 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 tab nanny.
So I thought that was funny. I thought I'd share that with you all. That's awesome.
And there's a thing called bad tabs.
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 class, that's also a good one.
Anything for you, Brian?
Nope.
Just working away.
The new office is working pretty good, but I've decided like it 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. 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.
What?
Yeah, yeah.
The next time you tell it, you could be like, hey, two threads walking in bar.
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.
Pipe joke. Pipe joke.
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 PythonBtes.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 Auchin, this is Michael Kennedy. Thank
you for listening and sharing this podcast with your friends and colleagues.