Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to
your earbuds. This is episode 201, recorded September 24th. I'm Michael Kennedy, and Brian
is not here this week. Instead, my friend and special guest, Cecil Phillip. Welcome, Cecil.
Hey, hey, everybody. I've been a long fan of the show. And so, you know, Brian, I'm sorry that
you're not here, but I promise I'm going to do a good job and do you justice. So I'm going to do
my best Brian impression today on the podcast. Beautiful, beautiful, beautiful. So Cecil,
you've been on the show before. You're a developer advocate at Microsoft. Is that right?
Yep, yep. Still developer advocate. And as folks can imagine, we're all at home and not traveling
as much as we used to anymore, which, you know, is usually something that's attached to the job. But
now we're just trying to find different ways to kind of reach out to the community and work with
folks and make sure that they have what they need to, you know, just be successful and productive.
Yeah, absolutely. And you're doing a lot of live streaming stuff these days rather than
appearing in conferences.
Yeah, we're doing a lot of live streaming, a lot of live events and even, you know,
live conferences too. I think a lot of conferences now, and you've seen this a lot as well with
PyCon and tons of the other, tons of the other online conferences is just because we can't do it
physically together like we're used to, you know, now a lot of folks just doing it online. So,
you know, I'm sure if you'd look online, you see tons of, you know, register for free. Here's my
conference on Tuesday and Wednesday and Thursday. And, you know, everyone's just trying to find a
way to connect.
Yeah, it's got some interesting implications for accessibility, right? Like, I couldn't necessarily
go to EuroPython, but I could attend the virtual one just as easily as long as I'm willing to get
up a bit early. That's kind of cool, actually.
Yeah, that's one of the things I like about it the most is that, kind of like what you said, like
before, I didn't want to go buy a plane ticket to go to Australia or, you know, somewhere that's maybe
halfway around the world to me. But now I can have maybe not the same experience, but I could still engage
with that community of folks virtually by just signing into their YouTube or their Twitch stream or
whatever the case is. And I can get the content the same way. And it's great.
Yeah, absolutely. So let me kick this off with our first item, where we go from Python to speak
another language, you know, a little different cultural here. So we're going to talk about
talking from Python to C++. Maybe not what you thought when I said that, but really C++ is one
of these or C really the more low level is one of the reasons I think Python is doing as well as it
is these days, right? Like a lot of what you do in Python might be a little bit slow,
but you know what? You implement part of that package and see, and then all of a sudden,
it's a lot faster than things you might compare it to. And that's a lot of the magic. A lot of the
data science works that way and whatnot, right? Right. Yeah. So there's this article that I'd like to
point folks to that basically walks you through what it's like to call C and C++ code from Python.
So there's a lot of things to cover. That's pretty interesting. It talks about,
first, what do you get when you capacity? Obviously, you get something that's executable.
What it is, is actually different depending on the machine you're on, right? So if you're on Linux,
you'll get an executable and linked format, which is ELF. On Windows, you get a portable executable.
On macOS, you'll get a mock object, a mock.o, and so on. So it compiles to whatever machine
instructions you need. And then depending on what platform you're on, again, you can put that in some
central location so that compiled C library can be used by Python. So on Linux, it'd be user slash lib.
On Windows, what do you think? Windows slash system, system 32, something like that, Cecil?
Sys32 or something crazy like that. Yeah.
Yeah, exactly. Something there. But once you put it there, then your program can find it and you can
just import it. So there's different ways you can do this, right? Like you can use the C types library,
which is simple, sort of, sometimes simple. And you can just go and import C types and then just say,
here's a C DLL and point literally at the file, the output from compiling some C code and import it and call it.
That's pretty simple. Coming from Microsoft World made this DLL import type of equivalent.
That's why I'm not entirely sure. But there's some interesting things that you run into. Like,
so you get this library back, but it doesn't necessarily know what the return types are,
right? Like, oh, you get a function, you call it returns a float. Maybe it doesn't know what to do
with that. So you've got to like, as you import it, tell it, oh, you return a float here and here are
your functions that you can call and so on. So there's a lot of interesting things you can do.
If you remember your C, you have to set the calling convention, which can be really tricky.
Like extern C, oh my gosh. Is it standard call? Is it a C decal? I mean, there's so many variations.
Do you remember this? Like, did you ever do some C and just go, why won't this library work with that
other one?
I know now, like I'm looking through this document as you're talking about it and I'm like, oh my gosh,
this is bringing back so many memories.
Yeah. I mean, you remember like how hard these things were to get them right. And it reminds you
how nice it is to work with like more modern languages like Python. So there's actually an
interesting library called libffi. So this is a C library. So if you're going to write the C code,
you can use libffi. And when you compile it, as you compile it for different platforms and stuff,
it'll automatically figure out the calling convention for the functions at runtime.
Oh, nice.
So, so that's pretty sweet. So you can, I mean, this didn't exist to my knowledge when I was
trying to do these things. That's interesting. Another thing you can do is you can add an entry
point function to your code. And then Python will ask, basically you can call that and say,
you know, what functions do you have and what are their signatures? So there's a way
to have your library kind of introduce itself over.
It's kind of like providing metadata, I'm guessing.
Yeah, exactly.
Here's the structure of my stuff and I'm going to give it to you.
And now you can kind of understand it.
Exactly. Cause you don't have a header file or anything like that, that defines it. It's just,
here's the executable compiled functions go right. And so it gives you that metadata. Exactly.
Of course you find you, the goal is to have C++ code that you can call from Python.
And there's a Python specific, a Python friendly way to do this as well. If you're willing to work with a
Python type. So like PI object pointers and so on. And the way you would do that is you create this
entry point, but it's the function name is PI in it underscore module name. So if it was requested,
it'd be PI in it underscore request. Exactly. And so that returns all this metadata that says,
here's all the C stuff and the signatures and whatnot. So after going through all this stuff,
how you write the C code and you do it, it says, you know what, maybe you just want to skip that.
Yeah. Can we please?
Can we please? Yeah. So what you could do is you could write it in Cython,
which compiles to C, which compiles to machine instructions, or there's also boost.python.
I wasn't aware of boost.python. That's pretty cool. And pybind11, which allows you to bind,
I believe to C++ 11, which is pretty cool as well. Yeah. So really nice integration stuff there.
And some examples of libraries that people might know of that are written in Cython,
but basically natively compiled and do awesome stuff is AIO HTTP.
Oh, I didn't know that. That's cool.
Yeah. Yeah. Use the Cython for the HTTP parsing. So that string stuff is super fast. If you do async,
you can, one of the things that's interesting in Python about Python's async as a wait,
and a wait is you can change the implementation of the underlying of the event loop. Right. And so
one way you can do that is you can replace it with UV loop, which is based on libuv, which I always
thought of as a C library, but it's actually fully written in Cython.
Oh, I didn't know that either. Really? Yeah. That's pretty cool. Then finally,
HTTP tools, bindings to Node.js HTTP parser is fully written in Python, along with Sanic,
UV core and a bunch of other stuff that use this library. So if your goal is to try to get a little
bit lower level, maybe work with some C, make your code go faster. Here's a really cool write up of how
to do all those things. That's really cool. You know, I'm a big fan of language interoperability in
general. Yeah. And you know, one thing I could tell you, it feels like every language knows how to work
with C, at least. Like C is like the common denominator that every language knows how to like
talk back to. And I really wish there was a way for us to, I mean, I love C. I used to love C. But I
really wish there was a way for us to like, have like a very standard way to like interact with each other a little
bit better. And I remember, I think the last time that I was on the podcast, I talked about
Wazi. So I think it was a WebAssembly. Yes. It's like a WebAssembly module that you could use.
And now all of your code compiles down to WebAssembly and it exposes different functions and
whatnot. But now that that'll be like a portable runtime, but essentially I can, I can import it in
Python and I can import it in Java or JavaScript or .NET or whatever the case is, because they all have
that, you know, that knowledge of how to work with that WebAssembly binary, right? That portable
WebAssembly thing. Yeah. I should look that up. I don't know where they are with that, but I know
that was a thing that folks were getting really excited about. Not just from the fact of, hey, I can run my
Python code or my language X code in the browser, but also too, I can consume it from other languages
that would make it. Right. If somehow you can package your code in whatever language you use in a WebAssembly
format, all of a sudden it becomes interoperable with other WebAssembly library, anything else that
can be packaged into WebAssembly basically, right? Right. And what's good about that is it's, it's
relatively a standards compliant way where, because WebAssembly is a standards based thing. It's not
owned by a company or one particular runtime. All of us run and play in the web and use browsers and use
browser technologies for one thing or the other. So it's definitely something that everyone can kind of
get involved in one way. Yeah, for sure. I'm super excited about that as well.
All right. Moving on to the next one, your topic here. You've got something very small that's
actually quite cool. Yeah. And so just kind of talk about interoperability a little bit. One of the
things that we all use a lot as developers is Git, right? Like I use Git a lot and particularly in the
GitHub space. Actually, I don't think I know a developer today that does not have a GitHub account,
but you know, maybe that happens. Do you remember when people used to debate about what kind of
version control they use? Like, oh, we use Perforce. Oh, we use Subversion. Oh, we're still
on CVS. We use a WinC. I use Tortoise CVS and I got a right click. That used to be a debate.
That debate is gone, it seems like.
I remember, man. I remember there was a debate back when Git first started too. There was a debate
between Git and Mercurial because those were the two distributed version control systems. And people
were like, oh, I'm going to use this one. I'm going to use that one and trying to figure out like
which one that was going to be the thing to use. But I think it's pretty safe to say that
in GitHub have won. Yeah. Pretty much. Yeah. GitHub too. Yeah. GitHub's awesome. Yeah. I think
they've pretty much just won. So now this article, why I think this is really interesting is, you know,
as a developer, since we, again, Git is pretty much like the standard of source control for all of our
projects. It's important for us to understand how Git works, or maybe you might be curious about what the
underlying internals of that looks like. And so what this is, is a really cool tutorial.
It's an interactive tutorial that you could do kind of in your browser as well, where you could
play around and implement Git yourself, your own version of Git in Python. And I'm like, oh, that
sounds cool. Like, I definitely want to do that. Because one, I think, hey, you're just giving me
another project that I could get better at writing Python. But two, I can also really try and understand
what Git does. I know a lot of folks, you may know a few Git commands, but oh, man, like, I really don't
understand what rebase does. And I don't know, what's the difference between Git branch and Git switch? And
you know, like some of those types of things. And so I'm hoping like we could go through this tutorial. And by
implementing it, we could really understand like how the underlying data structures are different and how that
Git database is different.
That's so interesting. And thinking about understanding Git by re-implementing it from scratch is pretty
interesting. Yeah. And I think it's worth pointing out just the format of this article tutorial thing.
It's quite unique. So if you open it up on the left hand, the browser split 5050, the left hand
column is the description and message. And on the right, it's basically got a diff of the code that
you're writing at each step. So it doesn't look like you can execute or anything, but it's a little bit
like replet or something like that. Yeah, I'm looking at this. And I think I was trying to see
if you could click on this thing, if it'll take you to the source. But I think this is in addition to
just being a really cool topic. I think it's an interesting... Oh, it does. As you click around it,
it'll, it'll reload the side to like take you to different parts in the code. Yeah. Oh, does it?
Okay. Yeah. Yeah. So there it does. There you go. There it does it. But I think this is a really
interesting experience just for learning in general, right? It's very interactive. So I could read the text,
the verbiage on the left hand side, and I could look at the code and I can see how it changes on
the right side. So it's not just like, Hey, I'm just reading the super complex book about like get
internals. Like I can actually see the code, which, you know, for folks that like to learn by seeing,
it's a really good experience to be able to understand like what exactly is going on.
I might have to go through this. This looks really interesting. And
I might learn a couple of things by doing it for sure.
Yeah. Yeah. This definitely looks really cool. But now speaking in terms about learning,
like you had a topic you want to talk about, right? That has to do about learning, right?
I would say you and I probably these days we qualify as senior software engineers.
I don't know. I don't really want that title on me anymore. Cause I don't know. It sounds like I go to
an office. That's my title, but nonetheless, we've been around software for a while. Right.
And there's this cool article by Neil Kakar who wrote it. It is an in-depth write-up of things I
learned to become a senior software engineer. I love these things where people sort of look back on
what they've done in their career, how it's, you know, what went right, what went wrong, and just
trying to help other people short, shorten that cycle to get farther, faster, quicker, that kind of
thing. So there's a lot of lessons he talked about. And I just wanted to cover some of them.
I said it's really long. And so I'm not sure I want to go into all of it there, but so the first one was
he advanced his career by growing his skills and experience using different ladders of abstraction.
That's how I put it. So it looks, the first year or so he had basically learned the ins and out of
software. Like he knew his language, his compiler was working and I believe he's doing Python. So maybe not
his compiler, but all the stuff that he's doing to work there is pretty much figure out the software side
of things. But his software development cycle was like a small cog within a bigger cog and so on.
So he said, look, there's really the life cycle of the product. There's a life cycle of the
infrastructure and the business and like working your way and sort of out of that loop to understand the
bigger pieces really helped him do more than just like write code, but like really be a bigger part of
the team.
This is really interesting. And I'm kind of scrolling to the article again, as you're talking
about it. And it brings up to mind, like a discussion that I get a lot from some of the students that we
talk to, you know, with the different engagements we do. And that's always their question. It's either
one, how do I become a good software developer or how do I level up in my career? Like what are the
things that I need to do to step forward in my career? And sometimes I feel there's certain things that for sure you could
definitely do. But then I think that's only like 50% of it. And I think there's another 50% that's could be a
little subjective based on the area that you're in and the region that you're in. And like, what are the
things that you really want to do? Like, what are the things that you really care about? Like, I could
tell you when I first started, honestly, I was just, I was just trying to get a job. I wanted to leave
school. I wanted to work because being an international student that I had to worry about
like visas and, you know, green cards and all that type of stuff. And I'm like, the first person that
hires me, I'm gone. Like, that's it. Right. But obviously that's not something you base longevity on
when you think about a career, right? You want to think about, okay, now I'm working and, you know,
I, maybe I've spent a year or a year or two inside of the environment and you, you know, you know,
you know how to code, you know, how your deployments go. You understand your ticketing
system and all the scrum meetings that you have to sit in on, but now you got to understand, well,
well, how do I get better? And one of the things I always tell folks is, well, it's kind of like being
a specialist, right? Like what are the things that you want to get better at? Because there's so many
different things to look at. What are some of the key things that really interest you? So do I want to be
really good at doing security? Do I want to be really good at doing performance? Do I really want to
get good at maybe microservices and distributed systems is interesting? Right?
Right. You get pigeonholed and people will just leave you there if you don't try to stretch.
Right. But you have to want that though, right? Like you have to want to get better. And then after
you have that want, you got to figure out where exactly do you want to go? And then for me,
then the next step after that is really trying to understand, well, what are the fundamental pieces
that I need to understand? Like what are the fundamental algorithms and data structures I need to
understand? And I'm not talking about like link lists and bubble sorts and that type of stuff,
but like within that space, right? Like, so in, when we talk about security, like what are the things I
need to know about cryptography? Right. When I talk about like distributed systems, what do I need to
know about networking and how networks work? You know what I mean? Like how do I get the knowledge to
understand that? So now I could continue to move forward and really become like very knowledgeable and
successful in that particular aspect of software development.
Yeah. I think that's a really big part of it. And that's definitely some of the stuff they were touching
on. I think one of the big levers you have to pull is to try to get yourself to do stuff that is
uncomfortable, right? Like I don't really know about continuous deployment, but we don't have a great
answer for that. So I'm going to force myself to learn that and I'll volunteer to be the person to make that
happen, even though I'm not totally there yet. Right. But that'll get you there if you take those steps.
Another one that Neil pointed out was learning what people around him are doing. So not just what are
the developers doing, but what are the project managers, the salespeople, the analysts and so on.
You know, for you working in a company like Microsoft, there's layers and layers and layers of that, right?
Yeah, for sure. And you know, there's good and bad things to that. One of the good things I like about
that is that there's always people that you could ask a question to. And sometimes you might be in
environment that that's not really the case. Sometimes you're in a company and everyone
is at the same level that you are. Yeah. You can't talk to other people, at least,
or maybe you don't have access to talk to other people. But when you're in an environment that
there's a lot of folks that you can ask questions to, one of the best things that you could do for
your career is make sure that you spend time with them, however that works, to really understand like,
how does their world kind of move? Particularly if it's something that you're interested in.
So again, like, hey, I don't know a lot about security and I have a security feature I need
to work on. And it's something I really want to dive deep into. Let me go and find the PM that does
security for this thing. Or let me go and find the person that works under Docker integration for this
thing or the Python integration for this thing and really have like a deep conversation with them.
And the good part about it, if that person is willing to sit down with you and give you the time,
that is like gold. Like it is the best thing ever to be able to have someone pass on knowledge to you.
I say that too, because we move forward. And as we become quote unquote, senior engineers,
we have to remember too, that the folks that are coming that are not so senior,
they're going to want to do the same thing for us, right? And we have to have that mindset of being
willing to share that information, not try and keep it inside and take it with us when we leave the
company kind of thing.
Yeah. Well, the other flip side is, you know, the best way to learn something is to teach it often.
And that's your opportunity. Yeah.
Yeah, exactly. Exactly.
Another interesting lesson was strategies for making the day to day more efficient,
which I suppose the larger the company, the more important this can be.
And Neil said some good habits. Notice was never leave a meeting without making a decision or having
a next action to do. Meetings drive me crazy. And it's so often you just have a meeting because
we always meet on Mondays for half an hour, even if we don't have to like, no, please not again.
Decide who's getting a thing done because if no, it's not on, you know, somebody's responsibility
to get it done is probably not getting done. And then document design decisions made during a project.
So that was pretty cool. Those are good ones. Yeah. Acquiring new tools for thought and mental models.
So one example in the software space would be like, it was recently struggling with the domain of a lot
of complex business logic and all these weird edge cases and stuff. And so found the domain driven design book
by Eric Evans and that whole space and said, oh, there's a whole world over here around like modeling objects
and relationships that I didn't understand or didn't know about. And diving into that stuff's pretty interesting.
Here's my favorite. And this has driven me crazy about so many different things.
Protect your Slack. So not your Slack, the not competitor, not your channel, but Slack as in,
I've got a little bit of time in my day-to-day schedule that is not clearly assigned, right? Not like
I'm spending the next two hours on this feature because I agreed to it in the sprint and then I'm done and I
have to move on to the very next thing, right? If it's so tightly packed that you don't have the
the freedom to explore, like
that didn't quite work the way I expected it. Let me dig into that. Or
what if we re-implemented it this way? Let me just try that idea. Or I don't know anything about domain driven design.
So let me learn. Let me spend the next hour reading about that and see if that'll help us later.
If all those opportunities are taken away and your time's like squished just back to back to back, you end up just doing 20 years of the same thing instead of actually growing and learning new stuff.
I'm a big fan of companies that allow their employees, developers or not, time to sit down and experiment and try out new things and whatever.
You know, prior to coming to Microsoft, that was in a company that they used to have, like every time there's a release, right after the release, they had this thing.
Oh man, what was it called? I don't remember what it was called, but it was like in events.
It was like a whole company event where for like the next week, all they could do was just work on side projects.
Like it was a whole week, right?
Oh wow.
Obviously the service folks had to be on service, but for everyone else, like the PMs, the engineers, the developers, you know, they spent this entire week just hacking on stuff.
And then the next week, you know, there was a day where they gave presentations and everyone talked about what they did.
And it was a whole showcase, but it was only internal.
It was just for the folks inside of the company.
And not only did you have time to do that and learn and try new things out, but you know, there were prizes, right?
Like they were, whether it was stock or money or like just, you know, there was stuff that you got, which was really cool.
So now it shows like how much the company like really believed in you.
And so again, I bring it up because I think it's an important one.
Not only do you give your employees, if anyone is an employer that's listening, that you give your employers, employees, the ability and space to learn, but also incentivize them to do it, right?
Like really encourage them and let them know that you're supporting it.
And regardless of whether that means it's something that's going to go in your product or not, like the fact is like they're becoming better, right?
And so if you, all of your employees are becoming better, like that means that they're going to be able to do better work for you at the end of the day.
And so I think that's always a really cool thing to do.
Yeah, absolutely.
I think this concept of Slack is super important.
And so much people looking from the outside, they try to squash it and compress people's time down.
And I think it's in the end, it's not so good.
So there's a ton of other stuff.
I want to just throw out really quick.
One last thing in the sake of time.
So we don't spend too much time on this.
The last was this idea of building up superpowers.
So are you getting into the source code of some project, some package and the documentation isn't enough?
All right, you have a quest.
That's to go read the open source code and spend some time like learning from the code, not from the docs.
You want to quickly build a mental model for code you're looking at?
Reading open source code again.
Embracing fear.
You're something you're not competent or feeling comfortable with.
Do it as a side project.
That's your quest.
Confidence to express ignorance or not knowing.
Like, fine, right?
Just we all got to ask questions we don't know and get over it.
And think you practice with that.
There's just a lot of good takeaways from here.
And like, we really just scratched the surface on it.
Sure.
And kind of going back to that point about reading the open source code.
I think that's one of the reasons, too, why GitHub is so popular.
Because it made searching source code so easy.
And I'm not going to lie.
There's a lot of times throughout my day that I'm thinking, hey, the documentation is not the best for whatever it is that I'm looking at.
I'm going to search for like the class or the method.
I literally just look for the class name and the method and filter by language.
Just to see, well, I just want to see how are other people using it.
And, you know, what are the types of issues that are created around it?
And, hey, should I wrap this in a try catch?
Or, you know, like what kind of parameters do you pass in?
Like, how do you deal with these things?
And being able to kind of look and see how other folks do it gives you some ideas now.
Okay, well, this is how this thing was meant to use.
Now, the flip side of that is that, you know, you might run into a bad example.
But, again, that's a learning experience, right?
Like, you'll run it and you'll figure out and then, you know, we're working out.
Yeah, exactly.
That's great.
So, speaking of learning, you guys have a pretty cool project.
A data source, I guess, to learn from or context to learn from?
Yeah, yeah.
So, what's happened over the past, oh, man, over months and months and months.
So, Microsoft actually started a project where they're working along with NASA to create these learning modules on Microsoft Learn.
And we can kind of go in and learn how to do, like, machine learning with Python.
But you could do it within the context of exploring space, which is really cool.
So, you could do different things like classifying space rocks and predicting weather.
It'll help you, like, predict, you know, rocket launch delays based on the weather.
Like, tons of great stuff.
And so, there's a...
I'm trying to think about how many are there.
There's a one, two, three.
Yeah, there's at least six learning modules, again, all based on Python and AI with machine learning and NASA, where you can kind of go in and learn all these different things.
So, definitely recommend that folks go in and check it out.
It's 100% free.
So, you could, you know, just click on the link and kind of go through them yourselves.
You don't have to sign up for anything, which I love.
Like, I love free learning resources, right?
But, yeah, I thought this was really cool.
And if anyone's a space buff at all, like, this would be a great adventure for you to kind of go through and kind of play around with some data from NASA.
Yeah.
To learn how to upset space.
Yeah.
And so much of being successful, especially when you're learning early, is about having context that inspires you.
Yeah.
Because we all get stuck or things get frustrating.
You're like, why won't it?
Why is this function not doing what it's supposed to do?
But if you're like, and if I get it to work, I get to understand a space rock or something like that, all of a sudden, it's like, yeah, that's not so frustrating.
Right, right.
And I think NASA also has, for folks that want to get a little bit more into NASA, NASA also has, like, I think it's called NASA Socials, which is like a national social club where you could, again, work along with other folks in the community.
Back before social distancing, you could actually go to a social event and you just learn different things about the work that they're doing with NASA.
So that's also really cool, too.
I think you could do those social events online.
So if you're interested, probably like, hey, maybe you learned a little bit in doing some of these courses and you want to engage with other like-minded folks that are into space exploration, but they don't necessarily work at NASA.
You know, that might be another thing to definitely check out.
Yeah, absolutely.
The next one I want to cover has to do with performance.
And I don't know if you've ever had this experience, but I have definitely had it where the code is going slower than I expect.
And I'm like, oh, it's got to be this part of the code that is so slow.
Yeah.
And then I profile it or I try to fix it.
And it's absolutely not, it has nothing to do with it.
That's like 5%.
It's somewhere else.
It's completely somewhere else.
Have you had this experience?
Yeah.
And you know what happens?
It's always a database.
Have you heard that?
There are no indexes.
Yeah.
People always say that.
There's like, oh, you have a performance problem?
It's always a database.
I know it's not always a database, but I totally get what you're saying.
There's definitely cases where, because who else would know your code better than you would?
And so if you're thinking, oh man, if this is where the problem is, this has to be where it's going.
Yeah.
Well, we just have such a, often we have a bad conceptualization of what is fast and what is slow.
Yeah.
Because I don't know, computers are so fast.
It's a little bit crazy.
Yeah.
But profiling is usually the first step to figure out what that answer is.
And then if you're going to change it, you can see, did it get better?
Did it get worse?
Where did it get better and worse?
And so on.
Right.
So if you're doing Django, I want to talk about profiling requests there, because there's a couple of interesting options.
So there's one library that will let you plug in basically C profile, which is the low level C profiler from Python that chips with it right into your request.
So if you plug it in, you can just do a question or an ampersand prof or question mark prof at the end of URL and you'll get a profiling output.
Oh, nice.
It's pretty cool.
So there's a thing called Django dash C profile dash middleware.
You just install that.
And then if it's installed, you can put basically prof in the query string and you'll get that, which is great.
And that gives you an output there.
Or you can put ampersand download and it'll download it.
You can visualize it graphically with snakebiz.
So that's even better.
So you get like this download profiling report for your request.
All that's pretty good.
But what would be a lot better is to be able to like visually dive in to the request and do things like understand, you talked about the database being slow, like understanding like the time you're spending in the database versus other places.
So there's this thing called Django Silk.
Okay.
And you also add that as a middleware, but then it keeps track of all the requests on your site.
Hopefully you're doing this in development, not production.
You keep track of all of those.
And then it'll show you like, this is the general time for this URL.
Click on it.
It'll show you things like these are the database queries that were run actually as SQL, even though using RM, it'll show you the SQL that was run.
It'll show you how much time the database is spending, how much time other parts of your code are spending.
So yeah, a really cool way to explore the performance from like all the tiers of your Django app.
Yeah, that's really cool.
And I always find database interceptors to be a really powerful concept, like across all languages, right?
Like being able to see like, like, let's say I'm using SQLAlchemy or I'm using, you know, Mongo Engine or something like that.
Right.
Like I'd really want to know what's the query that I'm sending over.
Like what does it think I'm asking for versus what I wrote in code, right?
And what am I actually getting back?
And being able to see, oh man, like this thing is doing like four or five joins.
Like I don't need to do that.
Like I could try and optimize this query a little bit more to one, make it more performant from a database perspective.
And then two, obviously passing on that, that performance over to my application.
Or I thought I did one database request.
Why are there 51?
Right, right.
Exactly.
Like, oh, that lazy property that, that we forgot about every single time through that loop, we're hitting the database again.
Like such a bad idea.
Maybe we should do a subjoin, like eager, eager load sort of thing.
Yeah, for sure.
Yeah.
So I think this is really nice.
Yeah.
Yeah, it is really nice.
And this is one of the scenarios too, where I think it's interesting to get like a log collector.
So, you know, there's tons of services that do this, but like something like Datadog or Rollbar or something like that, that not only capture your logs, but allow you to kind of go in and search through them, search and filter your logs.
So you could say, okay, well, hey, I'm having performance problems, but it only happens at two o'clock in the afternoon for some reason.
Or, you know, my memory always spikes within these hours of the day.
And being able to have a history of logs and be able to query them and then get that rich information.
And I don't know whether you plot it or turn it into a report or something like that.
Being able to do that, I think is hugely important.
Yeah, absolutely.
I totally agree.
And being able to visualize it, right?
So often having the picture is what you need.
Sometimes, though, it's good to just get a text.
Yeah, that's true.
Sometimes it's good to just get a message or get like an alert.
Hey, Michael, the website is going down.
You need to get here ASAP.
Exactly.
And so that kind of leads into the next one.
That was a good segue.
I like that.
Thank you.
So that can lead into the next topic I did want to talk about.
At the time that we're recording this, this week is actually Microsoft Ignite, which is, you know, one of the conferences that we do.
And it's all online.
We announce products and tons of stuff like that.
The last time that we got to actually see each other in person and hang out a little bit was at Microsoft Ignite in Florida.
And I was blown away at how ginormous that conference is.
Like you were on Talk Python then and Python.
Right, right.
That's 30,000 people.
So I guess it's 30,000 video streams now.
Yeah, I remember that last time we were all together.
It was in Orlando.
And Dan Bader was there.
I remember.
Yeah, that's right.
Episodes with Dan.
I don't even know what the numbers are this year.
That would be interesting to find out.
I should look that up.
Yeah, for sure.
See like what those numbers kind of seem like.
So it's been a year and you guys have a new announcement.
Yes, it's been a year.
And so there's a new service.
And so this is Azure Communication Services, which is cool.
One, because, you know, we have a new service.
But two, like I had no idea this was coming out.
I kind of found out like everyone else did on social media.
So this is Azure Communication Services.
And essentially, it's a way for you to add, well, communication services to your application.
So it does a lot of cool things.
Like it does voice, it does video, it does text messaging.
And you can obviously receive and send phone calls and things like that, which is really cool.
But what's even better about this, more specifically for the folks of this show, is that there's a Python SDK on day one.
I guess we could call it day zero since it's not officially out yet.
But, you know, on today, you know, in preview, while the service is in preview, there's a Python SDK, there's a JavaScript SDK, and there's also a .NET SDK.
And I looked at the code for the Python SDK, and there, I almost want to say like, there's nothing there.
I mean, obviously, there's something there, right?
But most of the code is like, create a directory, create a virtual environment, install pip, SMS client, that send message.
I'm like, wait, that's it?
Yeah, it's like, literally, the meaningful bit is like five lines of code.
Right, exactly.
And so it looks like a really easy thing to kind of get started with.
And so I haven't played with it yet.
Again, I just literally discovered this yesterday, kind of like everyone else did.
So I'm really interested in plugging it into some of my demos and seeing like what the experience is really like.
Yeah, this looks really cool.
If you got to send, if you want to add text integration, like text alerts to your app, seems like a really good choice.
Right.
And so then we could plug in, imagine if we could plug that into the Django profiler.
And then as things are happening, it sends us text message alerts.
And so now we can know, oh, there's a problem with the website now.
That's right.
It's running slow.
The memory's too high.
Exactly.
Check it out.
Yeah, that's awesome.
Nice one.
People can check that out.
I guess that's it for our items for the week.
Quick shout out.
I just say I was on, you mentioned Dan Bader.
I was on Real Pythons podcast with Christopher, the host there last week.
So I'll be sure to link to that.
It was a really fun look back on the trends and stuff I've seen over the last five years of podcasting in the Python space.
So if you want to hear about that chat, follow up on that show.
And then how about you?
Anything else you want to share?
One of the things that our team does is they work with students from different universities across the world.
And, you know, they join a program that we have that's called the Microsoft Student Ambassador Program.
Now, if you're familiar with like Microsoft MVPs or Docker captains or what is it called?
Google Developer Experts is something very similar to that.
But it's just this time we're talking about students.
Right.
And so, you know, these are students that are going out and they're creating content and doing sessions and workshops and, you know, writing blog posts and different types of things within their school and within their communities.
And so, you know, we have them join, you know, this program where we're able to support them a little more and give them Azure credits and Visual Studio things and LinkedIn learning things and some private events.
Yeah.
They have little private events and mentorship sessions and things like that.
But, you know, it's a really great way for us to kind of engage with the students.
Right. And I really just understand, like, what are they doing?
What do they care about?
What are some of the ways that we can affect their learning?
And so what I wanted to do was share the link to the Microsoft Student Ambassador website.
And you can actually kind of go here and you can search by region, by language, by area of focus.
And you can kind of see what the students are doing, which I think is really great.
And if anyone that's listening is a student as well, a university student that's interested in joining the program, you know, you go ahead and hit that big blue apply now button.
And, you know, go ahead and submit an application for the next for the next cohort.
I think that'd be a great opportunity for students.
So people should check that out.
All right.
Let's finish this off with a joke.
And we're better to go than XKCD.
I love SKCD.
I know they got some good stuff.
So this one is entitled Dependency.
And I think it just captures the whole bring together different languages and technologies and especially a bunch of open source libraries.
Do you want to describe this picture for the listeners?
You can always grab graphical stuff for our jokes.
Sure.
So this reminds me of a game of Jenga.
That's what I'm thinking.
Like a super Jenga.
This is like recursive Jenga.
Yes.
That's what this looks like.
And so there's some big blocks and there's some little blocks.
And it looks like as the closer you get to the top, they start to become a lot more specific with like the type of blocks that are up there.
And then at the bottom, it's much bigger at the bottom.
And, you know, that looks like that could be trouble.
Oh.
And then on the right side, there's one little part that's holding everything up.
And it's really, really small and fragile.
At the top, it says all modern digital infrastructure.
And at the bottom, it says the little tiny stick is a project some random person in Nebraska has been thanklessly maintaining since 2003.
That's amazing.
I love this.
In the hover over messages, someday image magic will finally break for good and we'll all have a long period of scrambling as we try to reassemble civilization from the rubble.
To me, I think of this as OpenSSL.
That little stick, that's OpenSSL down there.
There was like one person who maintained it and everything seemed to be built upon it.
And when there was that bug that needed to fix them, it was a huge problem.
I find anytime I try to home, so I use a Mac.
And every time I homebrew install OpenSSL and it updates the version that's on my system, like everything just stops working.
Like I can't install any pip packages.
Like nothing works.
I'm like, what happened to my virtual environment?
Like what's going on here?
Why can't I install anything?
Then I'm like, oh, OpenSSL.
Yeah, exactly.
That's the stick that can bring it all down.
Well, thank you for being on the show, Cecil.
It was great to catch up with you.
You had a lot of good stuff to share.
Hey, thank you for having me on.
And Brian, I know you're not here, but I hope I did you service and hope you come back soon.
And also too, I didn't get to say this in the beginning.
Congratulations on 200 episodes.
Well, over 200 at this point.
Remember, I listened to episode 199.
I'm like, wow, has it been like that many episodes already?
Like it's crazy.
Yeah, that's coming up on like four years almost.
It's insane.
Wow.
That's awesome.
Well, congratulations to you both, man.
That's a great achievement for podcasting.
Yeah, thanks a bunch.
And take care.
Take care.
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.