Python Bytes - #177 Coding is 90% Google searching or is it?
Episode Date: April 16, 2020Topics covered in this episode: Announcing a new Sponsorship Program for Python Packaging energy-usage Coding is 90% Google Searching — A Brief Note for Beginners Using WSL to Build a Python Deve...lopment Environment on Windows A Pythonic Guide to SOLID Design Principles Types for Python HTTP APIs: An Instagram Story Extras Joke See the full show notes for this episode on the website at pythonbytes.fm/177
Transcript
Discussion (0)
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 177, recorded April 8th, 2020.
I'm Michael Kennedy.
And I'm Brian Huckin.
And this episode is brought to you by Datadog.
Check them out at pythonbytes.fm slash datadog.
More on that later.
Brian, can you believe that it's April?
I really can't. It doesn't feel like it.
I know. I feel like we're still kind of in the winter mode, and yet's warm and sunny for the first time in seven months i've been told yeah well i'm doing
yard work but it was just sort of feel like we're gonna skip easter i don't know what's going on
there but yeah it's crazy times but at least it's it's warming up out there and that's that's lovely
so before we get into our main items i have a very exciting announcement that we were just
working on to let everyone know about.
So we're trying to find other ways for people to learn about or consume the podcast,
other ways that you can interact with us, you dear listener.
And so we are launching a YouTube project, a YouTube channel. So right now, if you can, and you're up for it, go over to pythonbytes.fm slash YouTube, click subscribe.
I honestly don't
know if there's going to be any content there yet probably probably maybe we're not 100 sure
because there's none now but by the time this episode comes out i think we'll have some and
the idea is each segment that we're covering we're going to have a dedicated little video
of brian and me talking and if there another guest, that'll probably involve them as well. And so it'd be really nice to have that for everyone,
I think, to just be able to quickly dive in
and watch a video,
see the two of us talking here as we see each other,
but also be able to just focus in on one topic.
I'm not quite sure how it's going to serve us,
but we'll put it on the YouTube channel,
probably put it on social media
and feedback would be very welcome there. I'm super excited for this. It's going to be great.
Yeah, absolutely. So am I. I'm also a little excited for PIP and the whole packaging thing
around Python. Yeah, well, I am too. One of the things I'm looking forward to, I think we covered
this a couple episodes ago, is the dependency resolver coming in changes in PIP, which is
exciting. But one of the reasons why
we're having i mean there's been a lot of packaging changes lately we've had relaunch of pi pi in 2018
some security features went in in 2019 one of the things i didn't know about was more support for
users with disabilities and multiple locales were added in 2019.
And there's been more security features and PIP and the dependency resolver are being updated for 2020.
And a lot of this has to do with some money that came in through some sponsorships and through a gift from the, I think it was the Facebook Foundation or something like that. But anyway, some money came in, but they were one-time things.
And the Python Working Group
and the Python Software Foundation
wanted to keep this going.
So they're launching an all-new sponsorship program
to help sustain and improve
the Python's packaging ecosystem.
And funds raised through this program
will go directly towards improving the tools
that all of us and your company uses every day
to sustain the continued operation of the Python Package Index.
And so I wanted to highlight this because I think it's really important.
And I depend on PyPI and packaging,
and I know my company does even more and more.
More people are moving towards more Python tools.
We're linking to this page.
One of the things on there is there's a prospectus for what you get as a sponsor,
and you can apply to be a sponsor there,
and there's a link to ask questions as well.
And then a note there that even if your company
doesn't want to sponsor you,
individuals can donate money,
either sustaining or a one-time thing too.
Yeah, I think the changes they've made lately or
have been in the right direction and i want to have it keep going yeah let's keep it going the
changes the major changes like the big rewrite of hypi.org happened because there was a grant i
think that one was from mozilla at the time but it was we actually have some money and some folks can
put their full energy for several months onto that project and guess what when you do that you make a ton of progress and stuff gets better and there are so
many companies out there whose primary technology stack is running on python they have billions of
dollars of revenue and they contribute zero back to python to keep that base that they are built on strong
so this is definitely a chance to encourage your employer to make you know a yearly sponsorship
donation or something like that to the psf they definitely need it now that python got canceled
that means less revenue for them as well so it's more important than even usual yeah and i think
it would be even
neat i mean a lot of people think about these we have the news there's news of these huge grants
and stuff and those are those are super nice but if all the companies that use python and you know
they're hitting pipey all the time even just pitched in like a couple thousand dollars a year
even yeah it would be game changing that'd be great yeah so yeah absolutely so on to another
good cause listeners probably know i'm very passionate about making sure that we address
climate change and move to renewable energy things like that at all of our infrastructure
and our content delivered carbon free we have a like a broader initiative to make sure that
we offset any of the resources
we might be using and so on so this next project is sort of in that vein and it's called energy
usage so the idea is it's a python package that will allow you to measure the environmental impact
of computation so you know we've had like profilers like c profile and we've had time it right so that's basically the
idea of this thing right but instead of asking how much time does it take you can ask how much
energy does it use and what you do is you give it a function you give it the arguments and you just
say run this function and figure out how much energy it uses. So it sounds silly, but it can measure how much CPU resources,
say versus disk versus network it's doing
and actually figure out how much computation
that's taking, right?
Because at the time,
it just tells you how long it took.
It doesn't say, well, actually 18% was CPU
and it was this high and so on.
And it takes all sorts of things into account,
like the loss of energy across the wires
how far you are away the location that you're in so it'll actually the report you get is like
this computation took 1.86 watts of energy and using geolocation we saw you're in pennsylvania
so that means you got 25 percent coal 0.17 percent oil, 30% natural gas, 42% renewable.
And that's how the energy was broken down for this particular run of that function.
And it's equivalent to, say, a certain amount of TV watching or driving so far or U.S. household consumption and so on.
Interesting.
Interesting, right?
Yeah.
So it's just a nice little package that you can point at some code that you're trying to profile and saying, how much energy does this use?
Should I worry about it?
Should I optimize it?
I mean, profiling is pretty close to giving you where you should focus your energy.
But if you want to know, okay, this is most of the computation, but how much does that actually cost in terms of carbon?
Or just more specifically, it's measuring energy consumption, which is also just something you have to pay for
if you have a data center then it's it's pretty interesting i think yeah we could get like maybe
a flake 8 package that would uh fail your your code if it uh if it uses too much or something
yeah yeah yeah it's pretty interesting it'll uh output pdfs you can run it where it doesn't put
anything on the screen but then it will you know save a report to a file or something like that does it include the running of the i mean how much energy does it take to run
the usage energy usage that's very meta yeah i don't know if it how much it actually is
computationally intensive but it is worth pointing out sort of because of that it only runs on linux
because of the system c CPU inspection parts of it
aren't built out to support other operating systems.
So you have to be on Linux to do this test on your code.
So anyway, EnergyUse, people can check that out.
It's a cool little package.
Now, before we move on to the next one,
let me tell you about Datadog
because this episode of Python Bytes
is brought to you by Datadog.
And let me ask you a question.
Do you have an app in production
that is slower than you like?
Using too much energy, maybe?
Its performance is all over the place.
Sometimes it's fast or slow.
But the most important question is,
do you know why it's slow?
With Datadog, you will.
You can troubleshoot your app's performance
with Datadog's end-to-end tracing.
Use detailed flame graphs to identify bottlenecks
and latency in that finicky app of yours.
So be the hero that got the app back on track at your company get started today with a free trial at pythonbytes.fm slash datadog cool datadog t-shirt included so brian this next one that you
put on here i almost covered it a few weeks ago as well and i was like yes this is really
interesting but then i don't know something else like there was a shiny object and it pulled my attention away so uh yeah this is a bit of a
philosophical one yeah so this is a we're linking to just a short little article but I wanted to
talk about the topic the article is called coding is 90 google searching a brief note to beginners
and there's really not much here other than saying that like i mean there's i guess there's three points in trying to learning how to program and a couple of them are good
in that uh just um pick one language to start with when you're learning in a program and of
course pick python and then start to do a project like try to do a project those are great ideas
and then the third point is um you get stuck, Google it.
And the point of the article really is, I think,
that coding is 90% Google searching anyway,
and people don't usually tell beginners that.
And I don't think I agree with this.
I was wondering what you think of this.
I don't think I agree with it either. But I'm not sure I agree with you yet either.
So let's talk about it because it is interesting and we probably do agree honestly i think programming developer career
evolution goes through phases and seasons and whatnot i think in the beginning you're just
super lost you just are trying to figure out syntax and whatever and then you feel really
good because oh i really got the syntax figured out and it turns out like that's a minor part of programming now you got like tracking down bugs and using
libraries you're like i gotta learn what sql alchemy is oh my gosh like what is a migration
okay google migration how do i do migrations well this isn't working let me like google and up at
stack overflow and in that sort of stage where you've crossed over, like I'm kind of a competent language user of the language,
but I'm not really like the world is actually open and all these libraries and packages are
out there. And I have no idea what I'm doing. Like, I don't even know what third normal form
is. So I better figure that out because it says I need it in my design for my SQL alchemy classes
or whatever. I think in that season of your career, I kind of agree with this. Like you're
just Googling like crazy and it's okay because Google is really good and the resources out there
are really good. But when I saw this article, I thought, okay, that's a pretty good message to
people who are kind of new. Like you hear how horrible it is to do copy and paste coding.
And yet this person is saying like, like they were in in i think a couple of years into their career
they're like look i do this a lot and i don't feel like i'm cheating or whatever and yet i don't feel
like if i had to put a number on it i would say coding is five percent google searching for me
these days five to ten depending on what if it's like something new i'm doing it's probably 10
to 15 but most day-to-day work it's five percent or less'm doing, it's probably 10% to 15%.
But most day-to-day work, it's 5% or less.
I don't know.
How do you feel about that?
I definitely agree.
Like, for instance, picking up a new framework or something,
I'm going to be looking it up a lot.
Right.
There's little spikes as you adopt a new thing.
But then it really goes back down, right?
But I was paying attention.
So I was thinking about this the last couple weeks
and paying attention to my coding style and i do there's probably at least a handful of times during
the day where i'm googling something but it isn't like everything it's it's definitely a more of a
five percent thing or less and then i realized that a lot of the things i'm googling is stuff
that i've just decided to not memorize right Right. Like the syntax of weird things.
Like I'm pretty sure that I can have a,
like a step size in range,
the range function,
but I don't use it very often.
What's that again?
You know,
things like that,
like extra stuff.
And a lot of this,
actually a lot of this stuff,
editor support really helps.
Anyway,
if I already know kind of what I'm doing,
the editor can pop up what the syntax is. That's a really helps anyway. If I already know kind of what I'm doing, the editor can pop up what the syntax is.
That's a really good point.
Because if I was using just pure Emacs
or something that had zero autocomplete,
I'd be Googling more for sure.
But on PyCharm, you hit dot and like,
well, there's three choices.
Then it tells you the parameters.
Like you don't need to Google for that stuff anymore
because you've got the better tooling.
Yeah, and there's different stuff.
So the syntax I leave to the IDE a lot,
there's definitely a skill.
So one of the things that I kind of missed out of this article
is it's not that Google searching is 90% of coding.
There's a big chunk of your skill set
is to learn how to Google something effectively.
So in coding, instead of
trying to summarize what the error message is and then Googling that,
oh, just paste the entire error message in. That's one trick to do.
And so there's a whole bunch of coding Google tricks to find the information
fast because I don't want it to be 90% of the time. I want something
that I kind of think I remember
to be able to look that up in just seconds
and then go back to coding again.
So yeah, I hope it's not 90%.
That would be a very slow way to code.
It would be, but I remember that being the case back in the day.
And for me, it wasn't Googling
because I think we had, when I was first doing programming,
you'll have to see if you can remember yours, but was using alta vista i'm pretty sure right like people who are listening
who don't know what that is that was a search engine that was nowhere near as good as google
that existed before google but the things you would end up there was not stack overflow to
search from and all those sorts of things and so it was a lot of books and a lot of user groups i'm not user groups like usenet groups whatever those were called so there was a lot of like
reference research stuff in the early days for me as well and i wish there was google i could
have done a lot more effective google searching but certainly i think that that is a just past
stage one of your career is is a this is a reasonable way to see the world but you're
right it's absolutely a skill and the more effective you can be at narrowing in the better
but then i think it actually is if people are living that life now like i'm googling all the
time this just must be like the rest of my life i'm gonna just do this that won't be the way it
is yeah i'm thinking back in my memory though when i learned to program there was no internet so there was um or if it was if there was i didn't have access to it so early 90s
late 80s it was books so i had references and still even even through my career early career
i had a couple books that that i would rely on because i knew i knew how to look things up
quickly so i had like
for instance i had like a sticky note right where the like the printf translator thing so if i knew
how to printf and scanf how what those little uh percent signs were and all that stuff so yeah
that's a really good point yeah so i remember my i had a c++ primer or something like that. And boy, that thing was all tattered.
And I use that a lot as well.
Yeah.
But it's not that way either.
It doesn't matter whether it's a book or Google or whatever.
It's a phase, but it's not all of coding for the rest of your career.
Right.
And then there's stuff that you just end up remembering that you like,
I'm never going to remember this.
I know I'm going to always have to look this up because there's some block like printf decoders and stuff like that yeah exactly
yeah like the stuff for parsing strings into dates like that is not that is always a google
search for me because i just i'm not going to remember all the details there yeah this next
one if i were to set this up this would definitely be a google search for me as well so i'm considering
setting but luckily i don't have to Google search it because we're covering the show
and Chris Moffitt is covering it.
He wrote it all up for us.
So Chris Moffitt wrote an article.
He's been on TalkPython before
and he wrote an article called
Using WSL to Build a Python Development Environment
on Windows.
So WSL is Windows Subsystem for Linux.
And this is interesting to me
because I just recently had this experience
where I finally broke down and I decided I've been using Parallels on my Mac
and I have a super fast Mac, like a i9 with six cores.
So it should be able to run virtual machines just fine.
And yet still when you're working in Windows,
you're working in any of the virtual machines,
like even a virtualized Mac OS,
it's still like the scrolling's a little bit off,
like the keyboard's tiny bits of late.
There's just a little bit where it just doesn't feel good to work there, right?
You can totally do it, but it's kind of, you can tell it's not a perfect experience.
So I finally broke down and installed Windows and Boot camp so i can boot into windows and have a
true native experience or just keep booting into my mac os and have that and that is a lot nicer
but one of the reasons i don't want to go to windows is i really love the terminal in mac os
way more than even on on linux it's just super nice and some of the tools you have there are like
in deployment on linux machines so you have this sort of closer to production the tools you have there are like in deployment on Linux machines so you have this sort
of closer to production world but you have a nice OS with like GUI tools and little widgets and
whatnot with macOS and I was thinking you know it's not really fair to Windows to like stick
into this little crummy system so it's nice to have this other option but I don't want to go
there and do development because I don't have this Linux type system right it's nice to have this other option, but I don't want to go there and do development because I don't have this Linux type system, right?
It's a nice terminal.
So what Chris talked about is basically
how to set up Windows subsystem for Linux.
And there's a new version that came out mid last year
called WSL2 that is a lot better,
especially around file performance and IO and sharing
and like crossing over between the windows and ubuntu or whatever you
choose to run oh cool do you do this any so i tried it really early on and i haven't tried it
since wsl2 is out yeah it sounds like it might be worthwhile so if you look at the this thing
chris wrote he talks about you know there's like a little motivation of how it runs and whatnot i'll
give people the lowdown but mostly it's like a step, a guide of how to set up the various things you want.
So for example,
if you want to be able to have a nice terminal
on the Windows side,
but then that can talk to the Windows subsystem,
it talks about installing the new Windows terminal,
which we already covered recently.
It talks about getting Ubuntu from the store,
how to upgrade old WSL installations
to like the version two.
Also how you can set it up
to use Visual Studio Code in Windows
that is actually like working on
the Windows subsystem for Linux.
So like you fire up VS Code
and you're doing your work
and then one of the environments you could choose
is like a WSL environment
that's actually running on an ultra lightweight version of Linux.
So you know when you get the little terminal in VS Code
and you type over there, right?
It's running Linux commands, but on your machine still.
Without a VM.
I mean, sort of a VM, but not really.
It's like halfway between Docker and full VMs.
This looks nice.
So what I am usually doing is,
I'll have to try this out again,
but I agree with you that I like to pretend
I don't have Windows.
But I do, I mean, my day job,
I work on a Windows machine.
So maybe this is extra helpful for you
because you're going to be there anyway, right?
Yeah, but I mean,
so I've already worked around most of it.
So I use Git.
So Git for Windows comes with Git Bash command,
which is kind of have both of them.
You can do Windows stuff and work around in Bash,
and it sort of feels like Unix environment.
Nice.
Well, I'm very excited about the possibility
of just having native feeling OhMyZShell on Windows.
Oh, yeah.
That's going to be nice.
Yeah.
Well, and I hope this is a direction that I think it is that this WSL stuff is just more and more integrated with the rest of Windows.
Yeah.
The integration is pretty sweet.
So if you're in WSL, which is effectively like you're in Ubuntu, right, you can type Explorer on the terminal and it will open up the Windows Explorer in that folder, in the Linux folder,
but it'll open up the Windows Explorer,
the native file stuff on Windows,
and things like that.
So the integration's pretty sweet now,
which is what I was thinking is worthwhile.
Also, to start up this WSL, it's like one second.
So it basically feels like starting a sluggish terminal.
Oh, yeah, it's so bad. Right, then it's up and running,uggish terminal. Oh, yeah.
Right.
Then it's up and running, right?
Yeah.
Anyway, so this is a really cool breakdown of how Chris is working and the various tools,
like the various plugins for VS Code and how he configured them to make them all work together
and stuff.
So if this workflow sounds interesting and useful to you, check out the article.
It's got a bunch of details and screenshots on how to do it.
And it's not really worth going into those.
But I think it's a cool idea,
and I just want to give a shout-out to WSL2
and doing Python on it.
Yeah, very neat.
You got a solid one for us, huh?
We've kind of kicked this can down the road a few times,
but I thought we'd take a crack at it.
There was an article written by Derek D
called A Pythonic guide to solid design principles.
Are you familiar with what the solid principles are?
Single responsibility,
open,
closed,
list cough,
substitution in something and dependency injection.
Yeah.
I forgot what the I is.
I is interface segregation principle.
There you go.
Okay.
Yeah. I had to look on that one.
I cheated.
I always have to look it up.
But I was curious.
So the article is interesting.
It's an interesting article.
So the idea is taking all these principles and I'm going to have to go through and spell check these.
But anyway, I don't even know where these came from.
But this idea that if you're
doing object-oriented design you should have solid object-oriented design i don't know if i completely
buy it actually i'm pretty sure that i don't but the this article goes in and also talks about
kind of relates each one to the zen of python as well and sometimes it's a little bit of a stretch and then also just really how to
apply these principles in programming and coding in python i guess i'll just say my take on solid
design principles are there are things that are good to know about and there's lots of different
design principles to know about and these are some of them and in developing object system systems with
objects and all python uses objects whether you think it does or not if you look at some code and
it's hard to maintain and it or it already is hard to maintain maybe some of these principles
might help refactor so that it's in a better state. But blindly following these rules actually, I think, could possibly make your code even worse is my take on it.
Yeah.
Well, I'm a big fan of design patterns, actually.
I really love the concept of design patterns.
And one of the things I love about them is once you start to think of code and design patterns, you can think of tradeoffs and higher level building blocks than just functions or here's a class you can think oh this is a you know this is going to be
an interface and so what that means is here's a benefit and here's a drawback and do we want to
go down that path right or i like that it lets you think in bigger abstractions than just lines
of code or functions so i'm a huge fan of that but one problem that i've seen a lot when people
adopt design first when they learn design patterns they become super passionate like oh my gosh this
is so awesome it could be so easy to go all right well these are going into everything like every
chance i can get to use the visitor pattern it's going in and you're like wait wait wait the visitor
pattern is super complicated and it only solves a problem, but it is really not obvious or easy to maintain.
The problem it solves had better be glaring and massive
or you're just making it worse.
And so I see this kind of stuff as salt
and pepper and paprika.
It's code is better with it,
but that doesn't mean it should be ultra doused at it.
You know what I mean?
Because then it's not better anymore. It's all of a sudden like, with it but that doesn't mean it should be ultra doused at it you know what i mean because then
it's not better anymore it's all of a sudden like this is a really cool study and design patterns
i have no idea what's going on like for example dependency injection like there's a few places
where dependency injection like at certain layers might be cool and you could apply it
and it's really neat but if you do it everywhere you're like i have no idea what anything is or
how any of them get to each other i just know that this is a complete mess and i need a debugger to even figure out
what's happening all the time and like that's kind of my feeling about solid especially in python
it's definitely my feeling about design patterns what do you think i have definitely have to agree
one of the and one of the things that um well i don't think i. Both design patterns and the idea around solid,
they were really developed for other languages.
I don't think they're definitely not the first tools that I reach for for making Python more maintainable and designed better.
For instance, like you mentioned dependency injection.
As far as I can tell, dependency injection should be used very
sparingly in Python. And there are great, great ways to examples, like for instance, in an
application that where you don't want to depend on a particular database style or database, you can
set up the database configuration early on and then pass that to the system but the problems with looking up if you
want to know more about solid and more about design patterns almost all the examples are going to be
not appropriate for python because they're going to be like you know java examples or c-sharp
examples or something right in static language examples yeah yeah i also think that they get
the way they get used,
they get used in this like overly general, overcomplicated way.
So for example, dependency injection.
I've got something I can maybe have a data access layer
and I want to be able to configure the type of database access it uses.
And I want to be able to configure the logging messages that it can send
or whether or not it logs to a file or at all, right?
You could take that and require everyone to always pass a database core instance to it and always pass a logger thing to
it or you could just have the data access layer have defaults and then you override them only if
you need to usually in testing so you can set them up so you always have to feel the pain of this
structure or you can set them up so you only even know that it exists
if you need to look into it and change it.
And I find a lot of times it gets used
in the hard way only.
But the problem is there's like a little bit of hard here
and a little bit of hard there.
Then you compose it.
It's a little bit more hard.
And at the top, you're like,
we need 20 things to like create this class
and get it started.
And I don't even know what they're for.
They've got to be passed way down.
And like, now we need IOC. Now i can't figure out where stuff is coming there's just a
lot of like layers that it adds on so i don't know salt i think is my best like spice yeah and
sometimes simple is good sometimes just a cookie is good yeah well you're right and you can always
that's right cookie's good you can always start with just write it the simple way and then add
the stuff if you need it right are you really feeling the pain that these kind of patterns
would solve okay bring it in right you got refactoring tools you got tests right yeah and
the other thing with the i mean solid includes things like the liskov substitutability principle
how arrogant does that sound i mean it's one of the things that just i
have a problem with is it just it reeks of i'm smarter than you because i know about this stuff
and i just don't like that but yeah yeah yeah it's a cool article though and the solid principles are
good to know even if you're not using them everywhere it's good to know like these are
some design principles and i'm choosing to use them here and i'm choosing not to use them there because right do it consciously right definitely
speaking of uh making choices and trade-offs instagram wrote a cool article recently that
i thought would be fun to cover because it's a look inside how they're running their django app
they want to basically take typed python like type annotations which they're loving right they
actually did a pycon presentation or i don't know if it's officially under instagram but uh lucas
linga covered basically how they're using types to add instagram when he was there and that was
really really interesting but they're like look we have a few http endpoints they have they've
talked about how they're not doing microservice they have a single django app and it has a few
thousand http endpoints in the one app on top of other stuff wow that is a lot of api endpoints
yeah and they all exchange like ripped rich types with validation And so they asked the question, are methods in code have type annotations?
We can check that with MyPy and stuff like that.
But how do we have developers know
whether their APIs are still matching what they should be?
Because everything returns a JSON result result or json response everything
takes an http post or a json object and like what are you going to do with that right so they went
on this mission to try to add this typing to their api so they came up with this decorator
though they can put on a regular typed method that converts it to an http endpoint in django okay
right so i've got a regular function.
It just, it declares its variables.
It declares they're of this certain type.
It returns them of another type.
And you just decorate this thing,
and boom, it becomes an HTTP endpoint
that returns JSON based on what it,
exchanges JSON based on what comes in and what goes out,
which is pretty cool.
So that's a start.
And it says, well,
you're still just returning JSON responses.
So how do you get better validation than that? So they decided to start using data classes
or data exchange because data classes have a type. They can be immutable because you can set
the frozen decorator on them. They have a type validation through things like my pie and whatnot,
which is all really cool. But but remember they have millions of lines of
code and thousands of endpoints in a single django app and they're not going to go well you know what
we're going to upgrade every single interaction to these data classes right there's a bunch of
dictionaries still going around so have you heard about typed dict yeah it's neat yeah it's really
cool so that comes out as one of the my pi extensions and it lets you create a dictionary
but then also express the types like this key is supposed to be an integer and this key is supposed
to be a date and so for the older code that couldn't be written with data classes what was
just dictionaries they added in typed dicks to help give validation to that and type explicit
type definitions instead of saying this thing returns a dick it can return a type that is a type dick
but still is compatible with the API.
That's pretty cool, right?
Yeah, this is interesting.
Yeah, it's super interesting.
They also talked about how do we...
Once we have these APIs
and they have types
and they have type validation,
how do we communicate that back to people
so they leverage OpenAPI
to come up with very nice documentation.
If you got the article open, Brian, you could scroll down,
you can see a very beautiful API reference
that was just automatically generated out of the API methods.
Yeah, OpenAPI is really nice.
Yeah, so that's really cool.
Now, what's also interesting is they go through this whole process
of what they've done and how they've done it,
and this is on Medium implicitly. It's on on their blog but their blog's running on medium so you can go and see the
comments in there and a lot of people are like hey this is cool why don't you use pydantic which
we've covered pydantic before it's it solves many of these problems for data exchange and validation
another person like you should use fast api because fast has this typed API methods natively at the boundary.
You don't have to like have this decorated that'll transform them into Django.
That's really cool.
But all of these are like, hey, I know you have a couple million lines of code for like
a huge, huge project in production.
Why don't you rewrite that in fast API?
No, right.
That's just not going to happen.
They're already in Django.
I mean, yeah, I was thinking, oh, it's kind of like fast api except for they're in django so yeah exactly
i mean who wants to take on the job of rewriting the entire millions of lines of code when they've
just gone through the progress process of going upgrading django and upgrading from python 2 to
3 and so on so there's a bunch of interesting comments about alternative ways to solve this problem if you were starting from scratch yeah but i think it's also interesting
to think about that now one thing that did come out that they could use somebody said this is cool
and if you have typed apis and nice documentation and you're already using open api why don't you
check out schema thesis schema thesis schema thesisema Thesis? Schema Thesis.
Schema Thesis.
So it's a tool for testing your web apps based on their API definition.
So it goes in reverse.
It looks at the documentation and it says,
okay, we're going to call your endpoint
according to the documentation
and see if it really matches that or not.
Yeah, it's really cool, actually.
Yeah, so I think that that's actually pretty neat i've never used this can't necessarily recommend it but it
seems pretty interesting if you've already got the open api stuff in place so i like that yeah
alexander holtner brought it up the schema thesis project up when we i talked to him on testing code
107 and it sounds pretty neat yeah yeah very cool all right well that's it for our main items
brian you got anything else you want to share with folks one of the things we've done for the
past couple episodes is talk about the current covet 19 stuff and working from home we didn't
mention that at the beginning but i've got like actually i wanted to just take this section to
like bring up some things that i'm running into. And I'm curious if any of our listeners have some comments,
but I'm curious about you as well, if you have any suggestions.
So you don't normally switch between Windows and Mac, is that correct?
No, not usually.
Actually, if I told you, I just got bootcamp booting into it,
and it's driving me crazy because even when I was using Parallels,
I remapped Control-C to be command c so even in windows i could do command c command v and in windows i
could do command w to close a window but now i gotta do alt f4 but oh yeah the crazy touch bar
thing doesn't have function key so now how to do alt f4 with no function key like there's just a
bunch of like yeah it's it's a challenge if I'm not running in a VM.
So yes.
Okay.
So I've got two laptops for one of them runs windows.
One of them's running Mac.
It's a Mac.
And so I've got my setup with my, like my monitor and my keyboard and everything.
And I can switch between them.
I would love to have just a magic switch but apparently usb switches don't happen
so i just plug in the usbc from one to the other so if anybody's got a switch that they know about
great but i don't want to pay like a thousand dollars i was thinking like 50 anyway what i'm
noticing is this whole the control c thing so on mac it's command c command v all that stuff it's great and then it's control
that's the thing i'm messing up is the copy and paste and all that stuff is different on the two
so any idea is it easier to can you remap on a mac can you make it do control c and control v also
i think so i'm pretty sure you can you can go one thing that i do all the time on the mac is if you
go to the keyboard preferences okay and then you can go in there you can. One thing that I do all the time on the Mac is if you go to the keyboard preferences
and then you can go in there, you can go to shortcuts.
And so I'll go to that app shortcuts.
So if you go to app shortcuts, you could add a new one.
You could pick all apps or just one.
So you could go and say edit means,
paste means this, copy means that.
And it might not always work.
You might have to add it for different apps because it has to match the menu item exactly so if one is like i don't know copy
and paste or i don't know like paste with a capital p or lower p or a dot dot dot or not a
dot dot dot those would not be compatible but you could go in there and add the shortcuts and just
say control control v means paste or paste dot dot or capital p paste or whatever
you got to do for a few of them and then i bet you could map it over like that yeah but the other
thing that you could do that i used for a little while is i had a windows machine and a mac at the
same time on two different computers and i set up a like a network kvm which is kind of what you're
talking about and it lets you actually
just have two monitors on two computers side by side and the mouse will just move straight across
from one to the other computer like without changing stuff so there's a place called
sharemouse.com i cannot recommend i've never used it i can't seem to find the one that i used to
search for and use back like five years ago but like a network kvm switch is what you want or
something like that so check that out that might let you like actually have both at the same time
maybe you can remap command to control across that as well okay the other thing is so we're
on episode 177 right we've done all these most of these episodes where i'm using a laptop and now I'm using a monitor,
is it distracting to do, and it's nicer to me to look at you while I'm talking,
but is it distracting to see somebody looking sideways while you're talking?
Right, right, because your camera's on your laptop,
but your main high-risk monitor is in front of you without it.
It's not distracting to me because i'm
used to it i there's so many video calls that i'm in these days where it's some sort of setup like
that okay i think i'm just overtaking it personally the person never looks at me like or you just
don't really like the way i look and you're always like oh geez no i'm just kidding okay no i think
it's okay i do have a logitech i have my macbook and the it would be off to the side
as well where the cameras but i got a little usb camera to go at the top okay maybe i'll get a usb
camera yeah who knows but okay anyway that was it and also for some reason i've got an hour and a
half extra with no commute time but i don't know where it goes i don't seem to have more time in
the day i seem to have less time but yeah
anyway maybe you're more accessible i mean you used to be like kind of accessible to the people
who are near you now the entire company has equal access to you and your time right yeah i've booked
it on your outlook calendar like oh no not my outlook calendar don't even look at that
yeah anyway okay so enough about me i don't know where
my time goes either but yeah we although i don't have more i've lost getting used to that although
i did have to drive my daughter to school and sometimes and that that time is back so yeah i
guess i have some time as well i have a quick follow-up really really quick so we talked about
super string and their benchmarks last week and the benchmarks showing that like super string is much faster on python and lower memory usage on python for a cool a bunch of operations and
whatnot and i convinced matt harrison to cover it and and whatnot but on twitter a couple people
were like hey i looked at the code and i don't really know where the memory improvements are
coming from if you look at the benchmark stuff honestly i don't know
how much better it is or isn't i haven't dug super deep into it but it looks like a lot of the
improvements in speed are around slices and like new string creation is not necessarily
that much better anyway i just wanted to link to a conversation with anthony satili and a few other
folks who are uh chatting about. So might want to jump in
if you really care about SuperString.
Yeah, and also I'm glad you brought it up
because I really love that people are calling us on stuff.
Like people pay attention and go,
hey, wait a second, you covered something
and I don't think that it's as cool as you think it is.
That's why we have awesome listeners.
Like usually the feedback is you
covered this one thing did you know there are seven others like it that you've never heard of
we're like no or why did you cover this other thing you don't know about well because i didn't
know about it till now yeah are you ready for a joke i am so ready all right this one is a little
bit we've covered this before but like 75 episodes ago or something like that so i feel like it's okay
to cover it again because i've talked a lot about Windows,
Windows subsystem for Linux.
You just talked about the sharing keyboard around it.
So, you know, in all good nature joking at Windows,
here's a joke.
So do you know how many programmers
it takes to kill a cockroach?
No, how many?
Two.
One holds, the other installs Windows on it.
That's funny. It takes way more than, the other installs a Windows on it.
That's funny.
It takes way more than one person to install Windows.
That's right.
Oh, fun.
All right, well.
That's good.
Good topics this week, Brian.
Thanks for sharing them with me and with everyone.
Thank you.
You bet.
Bye.
Bye.
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 Auchin, this is Michael Kennedy. Thank you for listening and
sharing this podcast with your friends and colleagues.