Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 311, recorded November 22nd, 2022.
And I am Brian Okken.
I'm Michael Kennedy.
And I'm Murilo Cunha.
So welcome, Murilo.
So tell us a little bit about yourself before we jump into the topics.
TLDR is, I'm a machine learning engineer at a data and AI consultancy company called Data Roots.
I'm from Brazil, but I actually live in Belgium.
And I guess that's it.
Thanks for having me.
Thanks for showing up.
It's great to have you here.
Well, Michael, why don't you kick us off with the first topic?
All right, let's kick it off.
I've got some fun stuff.
Let's see what Murilo thinks about this.
This is, it's a little bit mathy, what I got going on here.
That is not the right screen.
How about that screen?
So this comes in from one of the big friends of the show, Brian Skin.
And he sent me a tweet and it just says, what?
At Python Bytes.
And it's a quote tweet from somebody here saying, holy, latexify is the sexiest thing I've ever seen.
And look at this.
So when I studied a ton of math and the symbols of mathematics are really important and they communicate stuff like really, really quickly.
You can scan over and you see the symbol for the real numbers or you can see the symbol for subset or, you know, infinite sum.
And you're like, I know what that means.
When you translate that into Python or into computer code, it usually becomes something kind of gnarly looking.
Right.
So the example here on this tweet has a function called solve and it's solving the quadratic equation.
I guess just for one variation of the root, not the plus minus, but that's fine.
It just says like negative B plus math dot square root B star star two.
It's like symbol soup, right?
Yeah.
So this latexify thing, latexify, latex is the language of expressing those symbols the way mathematicians would have written them in, you know, the 16th century or whatever.
Like the fancy flowing sort of, you know, sum symbols and integral symbols and whatnot.
And so what this does is you just put a decorator onto that Python function.
You say latexify dot with latex, latex.
When you show that function in a notebook, it shows the math, formal mathematics of it.
Wow.
Like, like there's one that was doing, I said, the quadratic equation.
Another one that says if x is zero, return one else, return math sine of x divided by x.
And then the symbols is like this sort of like branching equation, you know, like what you would write that in latex conceptually.
What do you think?
Oh, wow.
Is that insane?
This is great.
But it just changes the ripple of the function, I guess, right?
Like if you call the function, it's all fine.
Yeah, exactly.
It doesn't change the function at all.
It changes the wrapper or the stir.
So if you do this outside of a notebook, what it prints out, let me see if I can somehow communicate this back.
So if you print it out, what it returns, do I have it here?
No.
Yes.
There.
No, that's not it.
Sorry, I don't have it.
What it prints out is the latex escape codes.
So it'll say like backslash frack of, you know, like it's a weird, I don't know how to write latex.
I did a little bit when I was studying math and then I said, that's something I never need to remember.
And, you know, shot it out of my brain.
Never again.
Yeah.
Like, why do I need to know this?
I don't need to know this.
Yeah.
So the wrapper is just the latex escape codes and then the notebooks see that and then they render it as latex.
That's pretty cool.
And then, but one of the nice things about this then is you can, you might have like the math that you're trying to convert to code and then you can like check your answer.
You can just see, did I get it right in code?
So, yeah.
It's pretty cool.
That's really interesting.
Yeah.
Could you round trip it, right?
Yeah.
I'm assuming people are doing this on their own code.
So they're, you know, I guess you could grab somebody else's.
It's the question about the inverse.
Yeah.
Right.
It's like, hey, if I have the math symbols, could I turn this into a Python function?
I mean, I don't see why I can't go both ways.
Sure.
Yeah.
True.
But I still think it would be easier to write the Python function than the latex code for rendering it.
Yeah.
That's true.
I think it's a pretty niche use case.
Well, you know, I'm sure.
Well, I'm sure someone's going to find a cool use case for it too, right?
Yeah.
This is pretty interesting.
We've got a couple of live comments.
Madison.
Hey, Madison.
Out in the audience.
Madison's been on the show before.
I'm blown away by how libraries like this are able to make math approachable.
I wonder how this could be used with auto-generated documentation.
Very cool.
I agree.
And Henry also says, I'm guessing it's working on the bytecode like Numba, but compiling it into a human language.
Yeah.
Compiling it into the latex escape codes.
Which is not human.
Yeah.
Which is the opposite of unilateral, but it is text, right?
And, you know, related to this, just.
Oh, yeah.
Henry.
Sempai.
Okay.
It's using inspect, get source and parsing the AST.
Yeah.
Perfect.
Another thing that's amazing, if people check out like the Sempai stuff,
it does some really, really interesting things.
Like if you go, say, to like calculus, you take a limit here.
It'll do similar outputs as well, right?
So you could put in this, and it'll actually express it as symbolic math, and it won't lose
precision because it solves it symbolically.
And you can say like, you know, back to this equation.
So that's kind of related.
But this just says, given any arbitrary Python function, not written in the symbolic form,
just turn it into a latex, which is pretty amazing.
So anyway, thank you, Brian Skin, for pointing that out.
That is pretty neat.
One final comment.
I could not get it to install on my Apple Silicon Mac.
Maybe that detail matters.
But I couldn't get it to pip install.
Out of PyPI, I had to pip install the Git plus the GitHub URL, and then it would install.
I don't know why, but if people want to play with it, that might be necessary.
Okay.
Yeah.
Over to you, Brian.
All right.
Well, while we're talking about math, I'm often working in the measurement world,
and where we care about prefixes a lot.
And a lot of people do, with big numbers or small numbers.
And this was actually suggested to us by Avram.
And I think he either works on this, or it's his project.
It's a project called Prefixed.
And what this does is it's just, it's a class, it provides a class called Float, capital F,
that is a, derives from the built-in float.
And it supports scientific decimal, or scientific and, yeah, IEC, which I'm not familiar with,
prefixes.
So things like scientific, like K and S and things like that.
If you go look at all the metric prefixes, you've got, like, there's some new ones, but
N, K, Mega, Giga, things like that.
And it just, so it adds these onto when you print them.
So it acts just like a normal float.
Most of the time, you can, you know, use it in math equations and everything.
The interesting thing is, if it is used in math, a math equation, the result will be
one of these prefix float types.
But then the nice thing about it is when you convert it to a string, it includes the little
prefix thing or the suffix or whatever, the little micro or K or M or something like that.
So I think this is actually super helpful.
I'm going to use this right away because I, you know, I use a lot of, like, big and small
numbers and reporting out just the huge thing or just the float is sometimes horrible to compare
with.
So this is, this is pretty cool.
It's very clever.
I love how, how simple the idea is.
So you can just F string one of these floats and say colon 0.2 H and that'll convert it to
its, and the H tells it to be either, you know, Killa or Micro or Mega or, you know, whatever
suffix is needed.
That's cool.
And then there's a, the byte example where they said, well, I'm going to, I'm going to
use the capital B for bytes, but that's after the, the formatting of the number.
And then the K comes in from the float thing.
So that's, that's pretty cool.
Um, one of the other things that he passed along is there's some new prefixes.
So this is, this is apparently new, new scientific prefixes over the last, for
the new first ones, new, new ones for the last 30 years, apparently.
So we have, 10 to the 21st, which is Zeta and 10 to the 24th, which is Yada.
And, then negative is Zepto and Yocto.
So these are fun.
Maybe why, why now?
Why they, they decided to like need to, they have more money now and they need to come up
with new, prefixes or exactly.
I'm not sure why we need new prefixes, but our microscopes can now see smaller things.
We don't have words for this, that things are this small, like, yeah.
But, national debt, maybe.
Um, yeah, very possible.
But, but also Avram notes that prefixed does handle these new ones.
So cool.
Good job.
Cool.
One thing, Python too, you can put the underscore, right?
To like, if you put underscore on the thousands, that also, that's something that makes it easier,
I think, to, to, to read the numbers too.
That's what I was using.
Yeah.
Like the digit grouping.
Yeah.
Do you do that a lot?
Not a lot.
I, but like some, whenever I can, I do, I think it makes it easier to, to distinguish
how big the number is, I guess.
I always forget to, I just, I know it's there, but I never use it.
Um, but I think usually it's like when I'm counting the zeros with my finger on the screen,
I'm like, no, no, maybe I'll just put a underscore there.
It makes it makes everyone's life easier.
Yeah.
I've really started doing that a lot the last couple of years, but before then I didn't.
Cool.
Well, what is next?
Merlot, what you got for us?
Um, I think that's me.
I think that's me.
Yeah.
Um, DBT.
Have you ever heard?
Of course you got to accept, you got to accept some cookies.
Hold on.
Oh, my bad.
My bad.
Just kidding.
No, I'm just teasing.
These cookie things drive me crazy, man.
I don't know.
Yeah.
I think it's like, it's crazy how like now that it's popping up everywhere and then you
see like the data, the gathering all the time and this and this and it's like, okay.
Yeah.
Um, but maybe DBT, have you ever heard of DBT?
Is this something?
Cause in the data world in my, my field, it's super popular, but, I don't know if it's
a bubble as well.
I've never heard of it.
Michael never heard.
Yeah.
I think I've, I think I've heard of it, but I couldn't tell you what it does.
So I was basically in the same spot.
Yeah.
Tell us about it.
No, it's a, it's a really cool tool.
It's open source as well.
They have their cloud, option, I guess.
Right.
So you can pay and they host it.
Um, maybe a disclaimer as well that I never, I always see it and I always want to use it,
but I haven't found the use case.
So I don't have first-hand experience here.
Um, but basically the way I would describe is that they add best practices around SQL projects.
So why am I, why am I mentioning this on Python bites?
Um, it's built with Python.
Yay.
Um, and the other thing too is that, yeah, they actually mix Jinja with SQL.
Right.
So you can actually do four loops.
You can do stuff like that.
So you don't have to repeat every time and just change the variable.
Um, you, they also have these like reference macros and stuff.
So you can actually say, okay, this comes from that table that is on that file.
And this comes from this.
So you can actually chain a lot of these dependencies, right?
Like there's a lot of projects that you have this ETL stuff, right?
So you just have to basically transform it each step.
And, with dbt, they actually keep track of what depends on what, and you can say, oh, I want the freshest data here and you execute everything that it needs to be executed there.
Um, wow.
Yeah.
So it's super cool.
They actually support a lot of like data platforms here.
Right.
So you see like big query data breaks, snowflake, all these things as well.
Um, another thing that they also more things they do.
They even have some data validation stuff, which in my field, it's a big thing too, you know, like maybe have an ID column that needs to be unique, cannot be null.
And you want to make sure that that always happens.
And if it doesn't happen, you want to be flagged.
Right.
So that's super cool.
Um, what else?
Ah, you also have some built-in documentation.
So if you, once you have the dependencies, you can say, oh, show me the DAG, you know, show me where the data comes from and what depends on what.
So that's also super cool.
And recently actually, they actually started supporting, so like an SQL file kind of corresponds to a model, right?
Cookies again.
Um, and, so they have SQL models.
So that's the, the one, but they also started supporting Python models.
Right.
So this is very tight to data.
So now you can actually mix and match, right?
You can say this step, this transformation is in SQL, but this one is actually in Python.
Right.
So the way they don't run anything on the machine, they actually send it to the cloud.
So snowflake has snow park, which is Python on its own snowflake.
Uh, big query has spark and Databricks as well.
Right.
So basically you can mix and match this transformation.
See, this transformation is there, but everything is like in a nice put in one place.
And because it's on Git as well, you can have CICD.
I think also you mentioned, I think it was you, Brian, that mentioned SQL fluff and SQL fluff actually came from a DBT project as well.
So, and it's all in Python.
So super cool.
Wow.
That's really neat.
So what do the Python models look like?
Are they straight Python classes or are they Pydantic or?
I have, I watched, maybe I'm a bit lazy because I just watched the video and they were, they were showing here.
Um, how, how it works.
Cause it's also doing a comparison, right?
Uh, maybe this is, can this, no, this doesn't work.
Does it?
Yeah.
It works.
Uh, no, this works.
Yeah.
It was wrong.
Okay.
Uh, this is, but the quality is horrible.
But in a nutshell, you have this basically, yeah.
You define a function.
Yeah.
You define a function that has a DBT and a session and then you create a reference.
So reference basically a table, right?
And you can say, and then from that point on, you can say two Pandas and then you can just basically use the Pandas API to transform that.
Right.
So there's still some caveats, right?
Cause Panda is not super performant depending on how much data you have and whatnot.
So sometimes you probably still want to stick to, the SQL stuff, but then it opens a lot of possibilities there too.
Right.
So even stuff like deploying machine learning models on the SQL infrastructure and everything.
So, yeah.
So it's, kind of the same old, same old story.
You know, even if you're working with an ORM, sometimes you don't want to bring all that data back to make some minor change.
And then you would just do a sort of an update statement instead of pull back 10,000 models, change something and call save 10,000 times.
Right.
Like it's probably that kind of trade off, but it's really cool.
That you can bring it back into Python this way.
Um, what are you using it for in your work?
Or like, what are you interested in using it for?
Well, I think we have a lot of these like ETL pipeline stuff, right?
A lot of these, we have some data here and then we want to like basically clean it up and make sure it's all uniform and put in a dashboard, calculate some KPIs and whatnot.
Right.
And so business people can see, are we doing better?
Are we making more money or not?
Kind of.
Um, and like a lot of the times it's just SQL, right?
It's also more accessible for a lot of people.
So we stick to SQL.
Um, but there are also limitations, right?
But before what I've seen is, people just kind of go in the UI and just execute stuff ad hoc.
Right.
So no versioning, nothing.
And I think this kind of puts everything in one place.
You can even add CICD because the CLI tool and everything, and just kind of make sure that everything goes to that versioned method.
Let's say, I mean, and again, yeah, if you need something more, more fancy, right.
Then you can throw some Python stuff in there, but usually we try to avoid it, to be honest.
I can imagine.
Oh, let's see here.
Uh, hold on.
Yeah.
The models, the, the way you express the code, it's like, it's really nice looking for SQL, which is surprising.
Right.
This, this code you write, like with customers as select these fields from this, this table.
And yeah.
And they have a, they also have like the different macros and like people can write different macros.
So like the describe function in Pandas, someone can just have written that and you can import that.
And like, it's, it's really nice to share like all these things as well.
So super cool.
Really, really eager to, to give it a try.
To be honest, I've been just like trying to scratch that.
Like scratch that.
Where's the next, where's the next project that we get to use this on?
Indeed, indeed, indeed.
Yeah.
All right.
Brian, anything you want to add before we jump over to, talking about our sponsor real quick?
Yeah, let's, no, let's talk about our sponsor.
All right.
So, today's episode of Python Bytes is brought to you by Microsoft for Startups Founders Hub.
So Microsoft for Startups set out to understand what startups need to be successful and created a digital platform to help you overcome those challenges.
And they came up with Microsoft for Startups Founders Hub.
The Founders Hub provides all founders at any stage with free resources to help solve startup challenges.
The platform provides access to expert guidance, skilled resources, mentorship, and networking connections, technology benefits, and so much more.
Founders Hub is truly open to all.
You don't need to be investor backed, but you can be.
Speed up development with free access to GitHub and the Microsoft Cloud.
You can unlock credits over time.
And there's also discounts and benefits from innovative companies partnering with Founders Hub, such as OpenAI.
You'll have access to mentorship, their mentorship network, which includes hundreds of mentors across a range of disciplines.
Need advice on marketing, fundraising, idea validation?
There's tons of topics, including management and coaching.
You'll be able to book one-on-one meetings with the mentors, many of whom are former founders themselves.
It's no longer about who you know.
Get critical support you need from Microsoft for Startup Founders Hub and make your ideas a reality today.
Join the program by visiting pythonbytes.fm/foundershub 2022.
That link is also in your show notes.
Yep.
Thanks, Microsoft, for keeping us going strong.
All right.
What have I got next?
This one is a chain of really cool things.
So, Roman Wright of Beanie Fame and other things tweeted about this project that Pablo Galindo Salgado has been working on.
So, Pablo was the release manager for Python 3.11.
It was part of the live stream of releasing.
That was all fun.
But he also, I believe, works at Bloomberg, where they work on memory.
And I think we spoke about memory quite a while back, Brian.
It's a memory profiling tool.
Maybe.
Merlo, do you use profilers and that kind of stuff in your world?
No, I haven't used much.
I haven't had a need, to be honest.
Not yet.
I feel like so far, there's no...
Try to keep it simple.
So, a lot of times profilers are about performance.
Like, how fast did this code run?
And if it's slower, should I look at this loop or that loop?
Or, you know, where do you spend your time making it faster?
Because it's really surprising when you look at code.
You're like, this part looks complicated.
So, that must be the slow part.
Like, no, that doesn't matter.
Nothing you do to that will make any difference.
You got to look over here, right?
That kind of stuff.
But memory, as the name would suggest, is more about memory profiling and, like, talking about,
you know, how many of these different things have you allocated and those kinds of things.
What is coming?
Well, first, let me pull up.
We have a pytest plugin, which is super cool.
So, with the pytest plugin, you can do two things now.
You can say pytest --memory tests.
And it'll tell you things like, you can actually set limits on how much memory can be allocated for a certain operation.
And if it exceeds that, it'll say, oh, my gosh, there's something wrong.
This thing is, like, way over using the memory we expected.
So, that's an error.
But it also gives you, like, a cool emoji-filled summary, I guess.
Like, total memory allocated, the number of allocations, a histogram of allocation sizes.
So, like, Python memory has, like, size classes.
We've talked about its block arena, one other term.
I'm forgetting.
Like, that it uses to organize data structures.
And then you can actually get it overall, then, for individual tests.
And so, it'll tell you, like, the different things that were, you know, allocated.
And anyway, it's pretty insane.
Okay.
So, you can get that report.
And then you can also, where's the other one?
I think it's, where was it?
There's a place where you put a decorator, and you just say, on this test, if it exceeds this amount of allocation, that should fail the unit test.
It's just a pytest.mark.memorylimit or something.
I don't think it's a limit or memory limit.
I can't remember exactly what it's called.
You can say, if this test exceeds one megabyte of memory allocation, then that's a failed test, which is pretty cool, right, Brian?
That's really great.
So, yeah, they have a limit memory decorator and a check leaks decorator.
That's the one.
So, the check leaks is the new thing.
And so, what you can do now is you can say pytest.mark.checkleaks as a decorator on your test.
And if there's a memory leak in the code that runs during that, it will let you know.
Wow.
I don't know if anyone else has tried to track down memory leaks.
I would rather track down, like, a multi-threaded race condition than a memory leak.
I don't want anything to do with memory leaks.
This is no fun.
And so, if I can do it with a decorator, let's do it.
Well, and also decorating your test so you're not having to modify your code at all to do this.
I mean, the code under test, you're modifying your test code, if at all.
Or it looks like it gives you some benefits even with no modification.
It's pretty cool.
Maybe, pardon my ignorance here, but when would I worry about memory leaks in Python?
I think, so imagine you're writing pandas, right?
And you've written a bunch of C code that's getting imported.
And you know there's a memory leak in there somewhere.
And it's just like, okay, well, I don't really know how to do it.
But then it's more like the C part is the bandage.
You can also have memory leaks in the sense that you expected there to be no more things
allocated after the function was called.
But you could have signed it to a global variable or you could have, you know, stored it, held
on to a reference in some way that you weren't expecting.
So, it's not a leak in the super traditional sense, but it could build up if you're doing
something wrong in Python.
But certainly outside of that.
So, I think this is pretty cool.
Really, any long-running service is going to have, you're going to be concerned about
it.
There's a lot of Python applications that are short-running and it just cleans up after
itself when it's done.
So, there's cases, long-running services, also things like maybe you care about, things
that are using large amounts of data and need all of the data that they can get a hold of
without wasting any.
That's important as well.
Makes sense.
I'm also wondering.
If you're right at the limit.
Yeah.
No, sorry.
Go ahead.
Yeah.
If you're right at the limit of like, I'm using 15 and a half gigs and I don't have more
than that.
So, I need that.
Or like, I just checked the Talk Python training site has been running for seven days and one
hour.
Yeah.
Like, if it had a memory leak, you know, it's even if it's, you know, 100 kilobyte here
and there, like it could turn out to be like a big hassle.
Okay.
Cool.
I'm wondering if you could use this for edge device stuff.
If we're going to limit the memory because we know the edge device won't have that much.
That's actually a really good point.
Oh, yeah.
Because if you're on one of these like CircuitPython little boards, they've got like 256k of RAM.
And that's very different than 16 gigs, isn't it?
Yeah.
Right.
So, you could test your application on a larger computer and limit how much memory
you give it.
Right.
Yeah.
I think you would want to do that with the limit rather than the check leaks, but still.
Yeah.
So, it's the same.
Yeah.
Cool.
Yeah.
Awesome.
All right.
Let's see.
A couple of comments from the audience.
Gareth out there.
Hey, Gareth.
Says, I ended up writing Docker containers that swapped out every couple hours to solve it.
I mean, that's actually what a lot of people do.
They're like, you know what?
If it runs more than 12 hours, it's a problem.
So, we just tell it to recycle itself.
And then Madison says, this is so cool.
I need memory profiling all the time with some of the data I do work with regularly.
So, people are digging it.
Cool.
Yeah.
Very cool.
So, thank you, Roman.
I know you didn't send that to us on purpose, but you shared it with us anyway.
Thanks.
Nice.
Over to you, Brian.
Okay.
Before I get on to the next topic, I want to point out that Henry Schreiner, I'm going
to paraphrase him by saying, Brian, you dork.
You didn't even read the article.
Yes, you're right, Henry.
Sorry.
So, the new prefixes, I was showing the previous new ones in 91 when they added yocto and zepto.
These are not the new ones.
The new ones are down here with ronacueta, ronto, and quecto.
Yes.
The reason why those sounded familiar is because they've been around.
These new ones, they're the new ones.
Okay.
So, thanks, Henry, for clarifying that.
But on to the next topic is Will McCoogan says, please steal my source code.
So, he wrote an article.
Will McCoogan wrote an article, stealing open source code from Textual.
And he says, I would like to talk about a serious issue with free and open source software.
Stealing code.
You wouldn't steal a car, would you?
And then, actually, he has this funny video that he embeds about how digital piracy really
is like stealing.
And it's sort of a funny video.
But the comment is real that, like, you need to, you can steal code from open source projects
as long as you can.
So, please read the MIT license or read the license to make sure that you can.
And in a lot of cases, you can.
So, like, I'm going to give an example that I use a lot is I'll think of something that I
want to do.
Like, I'm interacting with a library and maybe I don't quite get how to do that with the
documentation.
I could search GitHub for projects that use that library also as an example.
And so, that's a way to look at other source code of how to interact with a project that
maybe doesn't have the greatest documentation.
You can see how it's done.
I've honestly never thought to do that.
That's a great idea.
I'll go look at the tests and stuff.
I'm like, these tests suck.
There's not a single one that shows me, like, this use case that I'm looking for.
This is brilliant.
Some of the, yeah, I do that a lot with pytest plugins because I look at how other plugins
are testing their stuff.
And I'm like, oh, how do they do it?
So, the warning there is he's not advocating for piracy.
Open source code gives you explicit permission to use it.
And if you're actually just copying the whole thing, you probably should reference it and
use the same license.
Or if you're copying large chunks.
But the MIT license, for example, says it's substantial copying.
So, a little bit of copying is fine.
And Will says, Textual has some cool stuff in it that you might want to look at.
So, he's got a loop.
He points out some things you might want to steal.
The loop first and last.
So, he's got a loop iterator that he's got a couple versions of it that will not only
iterate through things, but it'll give you, it'll note which one's the first and the last.
So, if you need to do something cool on something different on the first and the last one, do that.
He tweeted recently or tooted or whatever about the LRU cache as well.
So, the Python's got a built-in LRU cache, but everything's global.
So, you can only kind of clear.
There's limits on how you can interact with it.
So, he has a more flexible LRU cache.
He's got a color class that looks pretty cool that you can convert to different color representations.
That's pretty neat.
And then, you know, he's been working on a ton of geometry stuff, 2D geometry.
So, he's like, you might want to use this for whatever 2D geometry you're using.
And so, here's there.
So, kind of cool, a reminder that open source, one of the benefits of open source is you get to see the source and learn from people.
I like it.
I love your idea.
You've never done that.
I'm like, it might dance.
I just can't figure this out.
Oh, how are other people using it?
So, I do that a lot.
I just get frustrated and go into a new library.
This one sucks.
I can't do this.
I'm going to find another one.
It's not good enough.
Merlo, are you an open source thief?
Do you do this kind of stuff?
I have to admit, yes.
Yes, I am.
Stack Overflow thief.
Open source thief is just, especially in the early, early days, right?
But I think with rich stuff too, it's very inviting for you to steal code.
Because even on the rich package, right?
Like if you do Python-M rich table or whatever, you always show some really nice stuff on the terminal, right?
And I was like, how does he do that?
Or like, I think for every component, he had a little demo that you can just run.
And it's very tempting.
Even if he didn't want people to steal stuff from him, I feel like you have a hard time just keeping the thieves away, you know?
Yeah.
Yeah, very cool.
And funny too.
I like it.
Good job.
Good job, Will.
Where are we at now?
All right.
Off to Merlo's final item.
Yes.
This one I had not heard of either.
And it looks pretty interesting.
Yeah.
I mean, it's a, I think it kind of, it's one of the things that I saw.
I was like, yeah, this makes so much sense.
Why?
How come I never, I didn't think of this before.
But this is Shed.
I'm a man.
This is a podcast, right?
So maybe Shed is, it basically, I think it's related to like bike shedding, shed your legacy code, right?
So it's like a superset of black, right?
They call it black plus plus here.
So they say here, a maximally opinionated auto formatting tool, right?
So it's all about configuration over, convention over configuration, which is also something that I can subscribe to.
They have no configuration options, but basically it's a bundling of a lot of tools, right?
So they have black here, but they also have eyesort and with the profile black, so it doesn't clash.
They also have pi upgrade, which I think you guys mentioned a couple of times, right?
Yeah, we did.
And autoflake as well.
Autoflake, I didn't know actually before.
But basically it removes unused imports and unused variables from your Python code.
So it's kind of like, yeah, that's all I wanted.
I wish I had this last week.
There you go.
Yeah.
But yeah, it's a one-stop shop.
And even do like a blackened docs, right?
So if you have doc strings or markdown or everything, you will take that.
It will black format that for you.
So I was like, yeah, this is what I wanted.
Okay.
Hold on.
Blackened docs.
This is new to me too.
All right.
Yeah.
Let's see.
So this is black on Python blocks, sample code blocks.
Yes.
So if you have rich structured text, markdown, even doc strings, it will format that for you.
Oh, like you like blackening your readme, for instance.
Yes.
Oh, okay.
This is good.
Indeed.
So I have some stuff to talk about at the very end, just a little bit about blogging and writing
and some platforms and stuff.
And that's all in Markdown.
Like I could run this against all of my code samples on my blog to basically auto format all
code in the blog.
That would be cool.
Yeah.
Yes.
Exciting.
The next time I write a book, I'm totally going to use that.
Yeah.
Or if you're doing a book.
Yeah.
I mean, absolutely.
So I literally just like yesterday, the day before I was cleaning up some code.
I finally got, you know, I kind of, I don't do it clean the whole time.
I get it to work.
And then I like, you know, then I look at what I did stupid.
And there's, there might be some imports laying around that I thought I needed because you add
an import and then you take that code out, but you sometimes forget to take the import
out.
So I ran black on everything, of course.
And then, and then I ran flake eight and I'm getting errors.
And I'm like, shoot, why didn't black just take those out?
So now I've got shed and I take those out.
It does it all.
Right.
Like it's, it's great.
Yeah.
Because maybe it's the same, right?
Like your flake eight is like, ah, yeah.
The unused variable.
Ah, okay.
They have to go there one by one, you know, it's like, it feels like there should be a
nicer way.
Right.
Yeah.
I mean, it's good.
You have to pay attention to that because your unused variable might be a typo or something.
You might think you're using it.
That's true.
Yeah.
Or it's like a global variable module supposed to share with something else.
And it's a library, but in general, I mean, you could probably put like a hash, you know,
QA or something on it.
Well, I mean, yeah.
And also you're, you're, you're testing.
So your test will catch it if you delete too much.
So.
Yeah.
All right.
Well, really, really good one.
Take your code out to the shed and whip it into shape behind the shed.
That's it.
All right.
Well, Brian, what else we got?
Extras?
I got some extras.
You got some extras.
Who should go first?
You go first.
Okay.
Well, the thing that I've been working on is, is by test check.
And I finally got, and I've been talking about this for like a month because I've been slowly
pulling this into shape.
It's almost a complete, not really a rewrite, but I moved everything around and the code's
a lot easier to read.
And so it makes me happy.
And I also changed the API.
So I wanted to mention to everybody that you can either use, so you can either use from
pytest check, import check to get this check object, or you can stick the check object as
a fixture.
And either way, you get access to everything in the library.
That's the only thing you have to do.
And for people unfamiliar, pytest check is a, is a library that allows you to have multiple
failures per test.
You know, normally the recommendation is try to fail on one thing, but sometimes you
need lots of data.
And I just threw in a little example that uses both.
So if like it's using HTTPX to grab, grab the status code.
And as long as the status code is 200, then I can check a whole bunch of stuff.
I can check to make sure the redirect and encoding is right.
And check for some, some stuff inside the, I mean, you, you, these could be multiple tests,
but if it really is, you're checking multiple parts of things.
And for scientific work that I'm in measurement work that I do, I'm often checking like a tons
of aspects of a waveform.
And it's really just making sure the waveforms right.
And that rightness is multiple checks.
So use that.
Anyway, I didn't intend to break anybody, but I did break Brian's skin.
So Brian came up at the beginning of the article, but he tagged me in a GitHub issue on his project.
And I looked at it and I'm like, oh, I didn't intend to break that.
So I fixed it this morning.
So hopefully if, if anybody gets broken by this, I was not intending to break anybody.
Just let me know and I'll try to fix it.
That looks great.
How about you?
Merlo, I know you have some as well.
I'll let you go as well.
Sorry.
Maybe.
Yeah, I feel like I should have opened that.
I didn't have the link up here.
But talking about breaking stuff, Flake 8 is not on GitLab anymore.
And I actually didn't have issues with that because with pre-commit, right?
You have to specify the repo.
I already was on GitHub, but I actually heard from people, some people that they heard a lot
of noise that Flake 8 is not on GitLab anymore.
And then there was also this video from Anthony that is maintaining, right?
Pre-commit and Flake 8.
He was explaining a bit because why, what was the motivation from going from GitLab to
GitHub?
And yeah, like what's relatable is that like sometimes you break people's code, but it's
like, it's not any intention, right?
But sometimes people can get very heated over these things.
So yeah, just maybe public service announcement, you know, change your Git repo to GitHub now
for if you're using Flake 8 as a pre-commit.
You also had Mastodon.py, right?
Yes, yes, yes.
That I did.
I just, sorry, I flipped the order because I thought it was, it was, it was a segue there.
Yeah, yeah, yeah.
I wish I knew about this like a week ago or so.
That would have been awesome.
You covered Toot, I think, right?
Yes, we covered Toot.
That's right.
Yeah, yeah.
So this is, to be very honest, I wasn't the one that found this, was my boss.
So shout out to Bart if you're listening right now.
But this is basically just a wrapper around the Mastodon API, right?
So you don't have to do requests.
You can usually have like a nice client library there to do all these things.
So if you want to play around, create some bots, you know, whatever, then yeah, there's
a nice convenient package now for you to do it.
Wow.
This is really cool.
And it has, you know what?
Documentations that say what functions it has.
I love it.
Documentation.
Just read the code.
It doesn't have to be much.
Like the seven or eight lines of code that are in the readme, like gives you a really good
boost.
But it lets you register your app, which is one of the things if you go to the website,
it'll show you which apps are registered for your access keys on Mastodon, but it won't
let you create one on the website.
So here's like a simple create app and just give it a kind of your instance name and what
file to save the access tokens over to and boom, you're good to go.
Have you guys already done stuff with the Mastodon or?
Yeah.
I, you know, on the stream deck, the thing that controls the stream, I already wrote that
thing where I, when I pushed the one button, it, it sends out the message automatically that
this live stream is starting.
And yeah, it uses, that uses a little bit of toot and mostly just the straight API with
HTTPX.
But if I'd known about this, you know, I already used it.
Now we know.
Yeah, I know.
Thanks for sharing that.
Anything else you want to share before we move on?
Yes.
So there are a couple more things, but this one, this is the, the, the, the, the,
Brazilian enemy that couldn't resist the world cup started.
I don't know if, are you guys soccer fans or not at all?
So we've a fun soccer team.
Here we go.
See, I go see with the kids and stuff in town.
Yeah.
So the, so I'm also in machine learning.
So a lot of data and like this time of the year, you know, there's a lot of like, oh yeah,
the AI models are predicting this.
This one is one from Oxford.
So I just wanted to give a quick shout out here.
So they, they have a video on YouTube as well, which is cool.
They explain the math.
And I, I will go on a limb here and say they use Python because they even mentioned Metplotlib
and whatnot.
But this is basically just a big excuse to say that they predict Brazil to win.
So, you know, if this doesn't happen, it's all rigged.
This, the math suggests, the math supports this.
So Brazil must win this World Cup and anything that is not there, I'm going to be extremely
disappointed.
This is really cool.
People are always looking for like realistic examples to learn and explore libraries and
tools.
And this, you know, if you're into soccer and you care about the World Cup, this is great.
Yeah.
I think if you, yeah, there's, there's people, people are very creative.
I feel like there's a lot of uses for it.
Well, I'm sure this will happen because there's absolutely no corruption in soccer.
Yeah.
For sure.
Yeah.
Not at all.
Cool.
Should I just keep going or you want to take over?
If you got more items?
Yeah.
Keep going.
Take us down the list.
I have two more.
Sorry.
I know you said I could have more than two.
So you can just wait.
That's what this whole section is about.
One.
So for me as a data scientist or machine learning engineer, we use a lot of notebooks.
Right.
And I think they have their place in data science, but there are some tools that don't, don't
play very nicely with it.
Right.
And I think in Git diffs or PRs, they don't, they don't play so nicely.
Right.
So this is a, I think it's public preview.
I want to say, but I haven't actually seen this, but now GitHub is going to start supporting
notebook diffs.
So if you have a pull request, they're going to have a nicer rendering of the notebook here
and you can actually see what the differences are.
And I think before there was a tool called review and be that you could add to GitHub.
But yeah, now they're just going to start supporting it.
So I haven't seen how it looks, but I'm pretty excited about this too.
One less headache for me.
Yeah.
That's excellent.
Because before the diff would just be like, here's the diff of the JSON file.
You're like, no, that's not what I want to say.
And also JSON is just JSON, like just key value.
So if you just change the order of some keys, it's just like, yeah, you have a lot of changes,
but it's not, you don't care.
Yeah.
Oh, this looks really useful.
Yeah.
And maybe one last, if that's okay.
Yeah.
Just pull this here.
This is Lancer.
So it's another CLI tool.
I talked about linting before, right?
So this is another kind of linting.
And I say kind of, because so, you know, some definition of linting or cleanup.
Yeah.
So this is like black, almost like black, but it's the opposite.
So instead of making your code look nice, it would just make it like a hideous, but working mess.
Right?
So these are some of the features.
It turns all your comments to pit bull lyrics or something safe for work, depending if you want.
It takes all your variable names and mix into like animal sounds and horribly look similar
looking characters.
So like bark underscore bark underscore zero, oh, oh, zero, oh.
It adds white spaces.
It adds completely irrelevant comments.
And the code still runs after these improvements.
So here's an example.
You have to hear some comments and everything.
So before, like nicely formatted.
And then afterwards, you see some comments like, bada bim, bada boom.
You know, there's nothing like Miami heat, some alpha characters in your variable name.
Pretty good stuff.
Again, I must say I haven't used this, but this is a tool that I'm not as excited to use.
I mean, there's all, there's always times that you need to send out your code to different places and you would rather share it less than more.
You know, like if you're thinking of like, if you make a desktop app and you got to send out the code for that or whatever, and you would want to obfuscate it.
You want to make it harder for people to just pick it up and like do something.
You could hit it with this.
They'd be like, yeah, no, no, we're just, no, we're just not doing that.
So my favorite one, my favorite ones on the screen is the, adding obvious comments, like, setting the value of some, like, that wasn't in the original.
And it's just funny that, I mean, that that's actually not gibberish.
It's just useless.
Um, it's, it's really good.
The, the, comments out in the live stream are really great, as well.
People are enjoying it.
One of them is it's great for Twitter employees.
You can maximize your lines of code for review as it's coming up.
Then you just print it out and you take a sidebar.
Like if somebody says print out my code so we can review it, they're not, they're not, equipped to review the code that you may have written.
Like if the word print involves in is valuing code, like, no.
All right.
Just, I don't think so.
So, leave that where that is, but you could, you could put this on top of like, yeah, I'm kind of funky when I write codes.
It's a little different.
Let's get used to let's yeah.
I just, it's a farm.
It's a code farm.
Yeah.
Oink, oink, oink.
Yeah.
You can have two sets of books.
kind of, you got your real repo and then you port use this to, to put it into the actual one that you submit.
Um, and you're like, I understand it.
I don't know what your problem is.
It works.
It works on my machine.
I don't know.
I kind of want to run this on a large code base.
I like something really complicated.
Squash all the commits.
Put force push.
Like, like textual.
Release it as textual.
Oink, oink.
Or something.
Yes.
I love it.
Cool.
All right.
Well, this was, this was a good, a good find.
Awesome.
Thanks.
All right.
I'll, I'll, I'll make mine quick here.
So a new YouTube video.
I talked about how you can install the Mastodon web app on your iPad as a native app, as well
as on your desktop.
So, if you're doing that kind of stuff, not there.
Basically they just released Mastodon four a couple of days ago and all the apps don't have
features like edit and some of the other features that are there because they're like months behind.
And so if you install the web app as an app, then guess what?
It looks like an app.
It acts like an app, but it has like zero latency.
So as soon as something is released on the website, you get it, which is pretty cool.
So people can check that out.
Uh, I saw Madison in the audience, sent over a call for proposals or calling all Pythonistas,
if you will, for Pi Cascades.
So Pi Cascades is back in person this year in Vancouver, BC.
It goes from Vancouver to Seattle to Portland and cycles through that, there.
But so this year it's going to be in, Vancouver.
So if you want to go up there and, talk, be part of the conference, good conference.
So call for proposals are open there.
Yeah.
But they're not open for very much longer.
So, jump on that.
Yeah.
I don't remember what the date is, but it is, it closes a Wednesday 30th.
So what is that?
Yeah.
Well, Wednesday.
Yeah.
Next Wednesday.
Yeah.
Eight days.
And Madison and I feel an audience.
Thank you.
It's put in person this time.
We, and we really value the first time speakers and atypical talks.
So get out there and put yourself out there and, and get into public speaking.
It's not a huge conference, but it's, you know, it's, it's big enough.
A couple hundred people, three, 400 people, fun time.
Uh, this is just really quick and fun.
You know, if you're on a Mac, you're not as likely to get viruses sent your way that would
actually be able to do something like 90% of viruses are written for windows.
But what's a really interesting fact.
I just, if you do have a Mac, it turns out 50% of all macOS malware comes from one single
app.
Can you believe that?
What is it?
Safari?
No, it's, Mac keeper.
So if, if you have Mac keeper, it like organizes your files and it'll like clean up your, your
junky cache and stuff, but apparently it has to take over so much permissions and it is like,
it can get, I guess, plug in there.
I don't know what it does, but people can like plug into this.
And make it to all sorts of horrible stuff.
So 50% of all malware is written for Mac keeper.
So if you have Mac keeper, maybe unhabit.
I recently, as a Sunday, launched a new website that I hope will bring me back to writing some
more.
We'll see about how that goes.
But here I'm, I'm trying a new philosophy on, on blogging, Brian.
I don't know how you feel about it, but I have a blog been doing it for a long time,
but like I looked the last article I wrote was like 2020.
I'm like, Oh, that's not so good.
And the reason is I would always try to write like 2000 word posts that are really, and I'm
like, but I could post to Twitter and mass it on all day.
And it's like, I can just do that.
That's no problem.
I don't like fall behind on Twitter.
That's because these really should be super short posts.
So I have, I've got this new website that I wrote that are just super short, you know,
fits on a page type of articles that people can go and check out.
So, yeah.
Some of the people, some people are promoting like today I learned things, but short, and
why not?
I mean, if you think it, if you think it's going to be a thread, write a blog post.
Exactly.
Yeah.
So cool.
So all of these are written, and this is all based on Hugo, which is a, just learned
about it, but a ridiculously cool static site generator.
Either of you played with Hugo?
I use it.
I love it.
Python.
So python test.com is written on Hugo.
It's ridiculous, right?
No, you haven't?
Sorry.
No, I haven't used it, but I heard of it.
Yeah.
I heard nice things.
Yeah.
So you basically just go to your directory of Markdown files and images.
You just run Hugo dash D server, whatever.
And then as you write, you have your, your web page open in your browser and automatically
sees the Markdown file changes or the CSS changes, regenerates it and refreshes your
browser.
Just so your browser could be just over there.
And it's just periodically as you make changes, it instantly refreshes.
So you don't even go and refresh the page to see how that you just write.
And the browser just watches and, and reloads.
It's cool.
Yeah.
And I, so you got it so that you just, you just push it, push your changes to GitHub or
your, or your repo for, and it just appears on your website.
Exactly.
Yeah, exactly.
So that was my, my next thing is then I set up a Netlify free account with CD and SSL custom
domain name push.
It just has a prod branch that I connected it to.
And when I pushed a prod, boom, it just goes there instantly.
So anyway, people are looking at that.
That is super cool.
Push the prod.
Oh, that's kind of cool.
I just, I just edit on prod.
So I just log in.
I didn't edit over SSH.
Yeah.
Just edit on the server.
The server is the backup.
Anyway, I have stuff on the screen, but there are no more backups.
That's just stuff I pulled up while we're talking.
So no more extras.
I mean, so yeah, fun stuff.
People check out the, the, the blog website and the video and apply for speaking at PyCascades.
Nice.
Well, I feel like Lancer also was like already really funny, but do you have anything else
funny for us or?
I do.
Although I somehow forgot to pull them up on the screen.
So give me just a second here.
There's two.
These are really good.
Okay.
These are, these are pretty, pretty epic.
So this one is called, I think Merlo, you'll, you'll really like this one.
Cause it has to do with like algorithms and data science and it's called messing with the
algorithm.
And it shows this, this dude here, don't mind the thing at the bottom.
I have no idea what that's about, but see, there's this guy whose face is blurred out in
UK.
I think I can't remember where this was.
I know Berlin.
And he's got a wagon, like a little red wagon that you pull behind you full of 99 phones.
Now what he did is he got them all running Google maps and left them open and started walking
down the street real slow and notice his neighborhood is now red on the map and he got it.
So it thinks there's a traffic jam and it'll send cars around his neighborhood.
Nice.
I want to get one of these so bad.
And whenever I take my dog for a walk, just walk with the wagon behind me too.
This is no cars.
Yeah.
So good.
Isn't it?
Yeah.
This guy's so ahead of our time.
He's just like, oh, he's so brilliant.
Yeah.
And for his neighbors.
Yeah.
The next one, the next one here is going to take a little bit of a, I just got a, I
got to set the stage.
Give me a second to set, set the history.
Have you heard of, you've heard about these motivational posters.
You go to like a dentist's office and it'll be like an eagle soaring over like a sunset.
Like if you don't spread your wings, you'll never soar as high as you could or something
cheesy like that.
Yeah.
Well, there's this company called, yes, exactly.
There's a company called despair and despair creates these, but like in reverse.
They're called the demotivators.
Yeah.
Nice.
So have you, have you seen these?
No.
Okay.
So here's one like solutions.
And what does it say?
It has like a Rube Goldbergian type looking thing here.
And it says solutions.
This is what happens when the problem solver gets paid by the hour.
It's just, it's just out of control.
Here's one.
What is this?
It's a frog wearing with a snail on its head.
It says collaborate.
So the best of us have to carry the rest of us.
It's just like, they're really.
All right.
So that brings us to, I feel like this is a Brian's skin show a little bit.
This, a tweet that he shared here and it, it has the latexify, latexify thing, but recursion.
And for the recursion, it has that demotivator.
It's a picture that said recursion.
Here we go again.
And then embedded in that is recursion.
Here we go again.
It's like that.
Yeah.
Like your screen share, you see your own screen.
Yeah.
So it's kind of like that poster, but for recursion.
Yeah.
I kind of feel bad that people, people that don't get the recursion joke, because they can't
even look it up because it just, it's redirected.
It just keeps going.
Like the definition is the definition.
That's right.
Nice.
All right.
Well, that's what I got for y'all.
Well, thanks everybody.
And thanks Michael, of course.
And thanks Merlo for coming on the show.
Thanks for having me.
It was great.
Yeah.
You bet.
Bye everyone.