Pybites Podcast

#195: Patterns, paradigms, and pythonic thinking with Rodrigo Girão Serrão

Julian Sequeira & Bob Belderbos Episode 195

In this ep, we chat with Rodrigo Girão Serrão about his journey from mathematician to Pythonista. What started as a colleague’s tip turned into 11 years of Python exploration. Rodrigo shares how his background in APL reshaped the way he writes Python, helping him embrace list comprehensions and functional patterns more intuitively.

We dig into his latest side project—a bytecode compiler written in Python—and what that reveals about how Python really works under the hood. Rodrigo unpacks dunder methods, decorators, and how Python’s consistent design makes building elegant, expressive code a joy.

He also shares great advice on giving talks: from deep diving into topics to letting ideas evolve before structuring a presentation. His love for community and clarity in coding is contagious.

Whether you're new to Python or a seasoned dev, this conversation will give you a deeper appreciation for the language we all love.

Connect with Rodrigo on socials:

Github: https://github.com/rodrigogiraoserrao

LinkedIn: https://www.linkedin.com/in/rodrigo-gir%C3%A3o-serr%C3%A3o/


Check our these links for some further reading/viewing:

RP podcast: https://realpython.com/podcasts/rpp/252/

The categorisation of the module itertools: https://mathspp.com/blog/module-itertools-overview

A tutorial on decorators: https://mathspp.com/blog/pydonts/decorators

An article about dunder methods: https://mathspp.com/blog/pydonts/dunder-methods

Why APL is a language worth knowing (article): https://mathspp.com/blog/why-apl-is-a-language-worth-knowing

How APL made me a better Python developer (talk/video): https://www.youtube.com/watch?v=tDy-to9fgaw

The series of articles with the compiler/interpreter: https://mathspp.com/blog/tags/bpci

A tutorial is not a long talk: https://mathspp.com/blog/a-tutorial-is-not-a-long-talk

How I prepare a technical talk: https://mathspp.com/blog/how-i-prepare-a-technical-talk 

Structural pattern matching: https://peps.python.org/pep-0636/ 

___

💡🧑‍💻Level up your Python skills in just 6 weeks with our hands-on, mentor-led cohort program. Build and ship real apps while gaining confidence and accountability in a supportive community. Join an upcoming Pybites Developer Cohort today! 🌟✅

___

If you found this podcast helpful, please consider following us!

Start Here with Pybites: https://pybit.es

Developer Mindset Newsletter: https://pybit.es/newsletter 💡

Pybites Books: https://pybitesbooks.com/

Bob LinkedIn: https://www.linkedin.com/in/bbelderbos/

Julian LinkedIn: https://www.linkedin.com/in/juliansequeira/

Twitter: https://x.com/pybites

Apple Podcasts: https://podcasts.apple.com/us/podcast/pybites-podcast/id1545551340

Sp

Rodrigo:

When I'm teaching something, it's not just about showing how to write the code with it. I think if folks really understand the point, then it makes it easier for them to use it later, because even if you forget the small details or the actual syntax, if you remember the idea then you can recognize. Okay, a decorator is what I should use here.

Julian:

Hello and welcome to the PyBytes podcast, where we talk about Python career and mindset. We're your hosts. I'm Julian Sequeira.

Bob:

And I am Bob Eldeboos. If you're looking to improve your Python, your career and learn the mindset for success, this is the podcast for you. Let's get started. Hello and welcome back everybody to the PyBytes podcast. This is Bob Eldwos. I'm here with Rodrigo Girão. You might already know him. He's pretty prolific and well-known in the Python space. But yeah, welcome Rodrigo.

Rodrigo:

Thank you very much, Bob. I was about to welcome you as well, but it's your own show, so I don't think I have to do that you can do that, you can do that, so I don't think I have to do that.

Bob:

You can do that, you can do that, so welcome.

Rodrigo:

Thank you. Thank you, it's a pleasure to be here, and I think, of everyone who's tried to say my name recently or the surname, I think you were the best one so far, so congratulations.

Bob:

Thank you. Yeah, I did a little bit of Portuguese, so that's a long time ago, so I really forgot everything you did good, don't worry. So you're based in the precious Lisboa, right? Yeah, or Lisbon, and yeah, as I said, probably quite some listeners already know you, but just in case if they don't, do you want to quickly introduce you to our audience?

Rodrigo:

Yeah, sure, let's do it. I don't think I'm that well known, so if you're listening to this and you don't know me, I think it's fine. Don't worry, bob is just pressuring you. But yeah, I'm Rodrigo. I'm from Portugal. I do write a lot about Python for some measure of a lot. I enjoy it very much. I teach Python. I've published or self-published some books about Python and mathematics and things like that, and I go to way too many conferences, or so my wife would say I think they're not enough, so we're still figuring this out. Yeah, I think this is the gist of what I do. Are you happy, bob, or did I leave something?

Bob:

crucial out. That's perfect. I will ask you more and then we'll get back on the conference thing as well. So you have a math background, right? How did you get into Python?

Rodrigo:

So the reason I got into programming was just because I was curious about programming in general. The reason I got into Python is the most random Actually, not that random. A colleague of mine in school just turned to me one day and said Rodrigo, you should look at Python, I think you'll enjoy it. And this was it. And I looked into Python and he was right, I enjoyed it, and so I've stuck with it ever since. And this was like what? 11 years ago maybe. So yeah, I just started programming in Python because of this colleague of mine. There's no special reason.

Bob:

Interesting. Yeah, it's kind of funny how these things go right, like I landed in Spain by a random afternoon where I just got piqued by the interest of learning the Spanish language and it was like out of nowhere. Sometimes those occasional comments can lead to a whole career changing thing. Yeah, programming is fascinating, but you also got into content creation right, because you self-published a book and you're posting a lot and you write these very insightful articles. So was that just a logical thing for you to do, or, um, yeah, do you? Are you as passionate about programming as you are, um, about teaching?

Rodrigo:

yeah, I think that's the. I think that's the thing. I I'm a very curious person and I mean there's plenty of curious people around, but I'm I'm very curious, so I really like to learn about different stuff. But then I cannot sit on that knowledge. I need to share it with someone, right I? I need to find someone that's enthusiastic about whatever it is I'm learning and then talk to them about it. And my blog kind of started because of that. In the beginning I just wanted a place where I could jot down notes about the small programs I was creating, but then it very quickly derailed and I started writing about mathematics and Python and programming because I just I apparently I like writing. And I started writing about mathematics and Python and programming because I just I apparently I like writing and I just love sharing. And if it's a blog post on the internet, then other folks can find it and read it and find it interesting and learn.

Bob:

So it was a very natural consequence of who I am Nice, yeah, and I find that through through the teaching, you learn these concepts so much more deeper, right, because you're really challenged and people might ask you a question like, oh, maybe I don't understand this so well, and then you start to dive deeper right yeah, you have to.

Rodrigo:

Yeah, there's no, there's no other way about it.

Bob:

Yeah, yeah so I was not sure if python was your first language, but you mentioned you also worked in APL, which I think stands for a programming language, which I think is pretty old right. So was that before Python and how has that experience influenced your Python style and thinking about Python and or about programming overall?

Rodrigo:

Right, okay, so that could be a very long conversation.

Bob:

That can be another podcast. People tune in next week for this deep dive.

Rodrigo:

My first language was Portuguese. My first programming language, I think, was Visual Basic or Basic, I don't know how to say it properly, because I just googled programming tutorial and the first result was a vb tutorial. So I started with that. And then, yeah, then python.

Rodrigo:

I started learning apl after I knew Python, but professionally I worked with APL first, and APL is a very old language and it does stand for a programming language. And I just want to say that it sounds like a terrible pun, but it's not a pun, okay, because when APL was first created it was not a programming language, it was a mathematical notation, an alternative mathematical notation. And very briefly, because I also don't want this to be a monologue, so maybe we can interact a bit about this, but very briefly, one day I realized that all of this experience I had with APL suddenly changed the way I wrote Python code, because one day I was writing Python code and I just wrote it, but when I looked at it I realized it was very different from what I used to write. So I recognized different patterns and different structures in my code that I then was able to link back to APL. So this is like the very generic statement yeah fascinating.

Bob:

So do you have an example of that? Was it maybe more functional or object? Because I think it can go both ways right yeah, yeah.

Rodrigo:

Well, let's think of an example, the apl the. The main paradigm is array oriented, so kind of like, if you're listening to this and you know numpy a little bit, how you're supposed to do these operations on whole vectors and whole matrices instead of like, iterating over a vector. That's kind of the, the bread and butter of APL. And so one very small example there's this thing called reduce. That in Python 2 was a built-in but it's now in the functools module. Python 2 was a built-in, but it's now in the FuncTools module, and reductions are sometimes I don't know advertised as difficult to understand and if you use reduce you're probably doing something wrong and it's complicated code, fine.

Rodrigo:

What APL showed me is that, or rather, sorry, the way they use reductions. They have a single symbol instead of having like a function, and then you can combine it with different operations to create all these different reductions. But because everything is a single symbol, whenever you use a reduction it's very easy to spot because it's always the same symbol. And so that ultimately led me to realize and it's obvious in hindsight, I'm not saying I'm a genius, I'm just saying that it became very obvious to me that some now I'm talking about built-ins and functions, sum and mathprod and any and all and stuff like max and min. You can kind of look at those as reductions and so if you realize that, it just makes it much easier to understand other reductions because you already you already know all of these that make perfect sense.

Rodrigo:

No one complains if I use sum to add a bunch of numbers. No one's going to complain about that. So I found that a very interesting example of the way it changed my understanding of the language. This didn't really affect much of the code I write, because I still don't use reduce a lot, but it changed my understanding. And yeah, I mean it's just, it's just fun when you suddenly realize that all these things are connected like some and all and any and broth and max, and mean you can think of them as being related to each other. I think it's very, very elegant, a very elegant idea.

Julian:

A quick break from the episode to talk about a product that we've had going for years now. This is the PyBytes platform. Bob, what's it all about?

Bob:

Now with AI, I think there's a bit of a sentiment that we're eroding our skills because AI writes so much code for us. But actually I went back to the platform the other day, solved 10 bytes and I'm still secure of my skills because it's good to be limited in your resources. You really have to write the code. It really makes you think about the code. It's really helpful.

Julian:

Definitely helpful, as long as you don't use AI to solve the problems. If you do, you're just cheating, but in reality, this is an amazing tool to help you keep fresh with Python, keep your skills strong, keep you sharp so that when you are on a live stream, like Bob over here, you can solve exercises live with however many people watching you code at the exact same time. So please check out pybytesplatformcom. It is the coding platform that beats all other coding platforms and will keep you sharper than you could ever have imagined. Check it out now, pybytesplatformcom.

Bob:

And back to the episode yeah, I love the built-ins, all these little building blocks, nicely isolated. Input in out, input output isolated, right, um. So what was um? So it varied. And under utilizing the built-ins before that, or what was some of the patterns in your python code, you thought later like, oh, this could be so much better all right, so maybe not necessarily a.

Rodrigo:

This could be so much better, but I I started to finding it much easier to write least comprehensions, reasonable ones. I'm not talking about the crazy ones where you have, I don't know, 10 loops inside the least comprehension. No, I'm talking about the reasonable ones. I kind of understood them or I kind of managed to write one when I needed. But again, because of the way APL is written and there's no way I can do this 100% over audio. You would have to either know APL or look at examples, right, but the way, yeah, well, there's no way about it.

Rodrigo:

But the way APL is written, because it's again about arrays and all operations are quote, unquote, vectorized automatically. When I started looking at list comprehensions again, I drew a parallel with APL code. That made it easier to understand why list comprehensions are written in the way they are. Again, I'm not necessarily saying that other interpretations are wrong or what I'm just saying. This new mental model suddenly clicked very much for me and and, yeah, from that point onward I was able to write least comprehension with my eyes closed, which I wasn't before.

Bob:

So it really helped me become comfortable with this python, with this python idea yeah, I think that's great point, like it's not only about syntax and understanding list comprehension syntactically, but also like what's the mental model? Why did they design a feature like that, right? So yeah, that brings us maybe on the next question what Python feature or features do you think are underrated or misused?

Rodrigo:

features do you think are underrated or misused? Well, if you dig deep enough, you'll find everything being misused.

Bob:

So, yeah, there's not. There's one uh unambiguous way to use uh, uh, yeah, not, not really yeah, so let's not go there, maybe, but we but we can.

Rodrigo:

Just before we started chatting, I was working on an example that used structural pattern matching, so the match statement.

Bob:

Which I think I learned for the first time in your book. I think you have that quite upfront. Okay, maybe If I remember correctly.

Rodrigo:

yeah, possibly. Well, that's's fun, I didn't know that, so I just remembered. Yeah, okay, excellent, that's awesome. Um, and I like so when I because I do like teaching a lot and I, I teach a lot I I'm always looking for, you know, good, good examples of these different features, these different synthetic features that Python has, so that I can, when I teach them, I can say, well, this is useful for X, y, z, and instead of just saying the match statement is for structural pattern matching, instead of saying just that I can show a concrete example and I don't see it a lot. It's also a fairly specialized thing, so I don't see it a lot, but I think people could use it a bit more if they understood better how you can match structure of different things and how you can do some pseudo-validation, because you can also match the types of things. So maybe the match statement is one example.

Bob:

I think that's a great example actually, because, at the core, if you just use it, as in the simplest base case of replacing an if, elif, elif you might just use the dispatch pattern right, where you have a dictionary and you just look up a key and you get the value in a sense right, which is more maintainable instead of adding lifs, ls. But yeah, pattern matching is actually incredibly powerful where you can have if, in those cases and uh, yeah, so you can do so much more and I I think people might not know or just not use that pattern enough. Yeah, they might not know, but there are more advanced use cases of that.

Bob:

Yeah, absolutely, and very ingenious stuff you can do with it, I think when the feature came out, there was some sort of example page on GitHub with advanced examples, so maybe we can link that, or maybe you have an article on that or you're creating one.

Rodrigo:

No, I do have an article on that, but I'm not sure I know. We have to find that other link you mentioned because, yeah, I will find it yeah, okay, awesome.

Bob:

Also, yeah, I have to call out the art of Python tips, right? Like we can all show an example of structural matching, right, Like we can all show an example of structural matching. But how do you make these examples interesting? Right, Always trying to find the use case that will speak to people and that really makes it interesting, which is kind of an art, right, yeah?

Rodrigo:

it's. Yeah. Well, for me it's also a lot of just trying random things, yeah, just figuring out what's going to click with others. Well, it's definitely not the science for me.

Bob:

Right. So going on to another thing, you're working on a toy bytecode compiler in Python. So yeah, tell us a bit about that. What's your goal with that and what have you learned from that so far?

Rodrigo:

Well, like I said, I'm fairly curious, which, to be fair, doesn't mean a lot, because probably everyone listening to this is a curious person. But I'm a fairly curious person and when I'm working with a new technology or with a new tool, I'll often find myself wondering how the hell did they do this? For example, a couple of years ago, I got very interested in neural networks. Couple of years ago, I got very interested in neural networks and I was taking a couple of courses at university where we talked about them and where we use them, and so, yeah, I tried building one and I failed spectacularly a couple of times and then I eventually made it and I re-implemented it from scratch and it was a very basic thing and it wasn't very powerful and it was slow compared to, I don't know, pytorch or TensorFlow or whatever you use, but it was fun and it was a surprisingly short amount of code and I learned a lot because I did it from scratch. And this idea of building things from scratch just for the heck of it, but also because it gives you a very deep understanding of what you're working with, is something that I don't think is given enough credit. You know, if you're working with something interesting. Just try to build it yourself. It doesn't have to be production ready, just do it for fun. And that's what's happening with Python itself.

Rodrigo:

Programming languages, the languages themselves, they intrigue me. How do you create a programming language? What does it mean? And this is a question I haven't answered for myself how can you implement a programming language? In itself? That upsets me. I don't know you're nodding your head, but that upsets me. How can I write Python in Python? Pypy is a thing, right, you write Python in Python, but then what runs the Python? That's running the Python. I don't get it. So that's something I'm going into. That's a road I have to go down a bit later. But just Python itself.

Rodrigo:

How does Python work? What's this bytecode? If you don't know Python, it's kind of an interpreted language, but before, what's being interpreted is not directly what you wrote. Python takes your code, turns it into bytecode. You can think of it as very short, very small atomic operations. Atomic in the sense that they're small. If you know a lot about it, then atomic has a different meaning, so sorry about that. But very small operations. And it turns it into this sequence of very small operations. And then what you interpret are these sequences of operations and you can see this with the module this. So if you import this as in disassemble, you can I don't know pass it a function, ask it to disassemble the function and you will see these bytecodes that make up your function, for example. So you've seen this before.

Bob:

Yeah, I have a tip on that. Awesome, you can get to that level, which can be very useful if you figure out why some code is more or less performant.

Rodrigo:

right, yeah, that's one example reason you'd use the module, the IS. This yeah, exactly, and it's just looking and peeking behind the curtain just gives you more understanding about the language. You just learn more about how things work, why they work the way they do, and I've been talking for ages about this, but that's the whole point. So how does Python work? If I wanted to implement it myself again, not a production-ready Python, but just a toy version of Python how would I do it? And so that's what I'm doing. I'm looking at bytecode.

Rodrigo:

I take small Python programs with the different structures I want to implement. I use the module, this, to take a look at the bytecode. I try to figure out what different things those bytecodes are doing, the different operations, because some of them have very funky names. So you have to somehow figure out what they're doing. And then I try to mimic that in my own program. I write a parser that takes the code and builds this nice tree representation of your operations. Then I take the tree and I turn, I compile that into bytecode, these sequences, your operations. Then I take the tree and I compile that into bytecode, these sequences of operations, and then I write the interpreter which takes these operations, these small basic operations, and actually runs them. I just find it very rewarding to write a small Python program with a couple of variable assignments and an if and then a leaf and maybe a loop and it just runs.

Bob:

And it's running on my own implementation of python that's fascinating, yeah, yeah, and going, and because python abstracts so much for you, right, it's really useful to do, because you might not even realize that whole conversion to bytecode you're just describing. It's just all abstracted away. It's the same like memory management, like when you learn Rust and all of a sudden you have to deal with this whole new system of the borrow checker and stuff. Right, you have to think about memory, right, and in Python we don't tend to do that or need that, because it's all abstracted away and there's garbage collector. So, yeah, I guess it can be daunting, though, like, you have to go into, you know, potentially learn some C. This is going closer to the machine assembly, right, but it's also not the point to make this very fast, right? This is all about, like, can I really reverse engineer what's happening when I run Python scriptpy, right? Yeah, exactly, that's really cool. It will make you a much better programmer.

Rodrigo:

Maybe, hopefully, we'll see. Yeah, but plot twist, I'm cheating a lot Because I'm running Python. In Python, I haven't implemented data types, for example. I just use the own numbers, the integers of the boolean. So I'm cheating a lot, but I'm also having a lot of fun. So who cares?

Bob:

yeah, sure, yeah, it's just for, uh, your understanding. So a follow-up question how do you research? So you mentioned dis um to look at the, the bytecode, um, but yeah, do you do you also? I mean the fact that you come up with this tree and learning the internals. I mean, I know Anthony Shaw has the CPython internals book, of course, but do you use AI for that as well? Just plain Googling? What is your approach to dive deeper, to get to that knowledge?

Rodrigo:

Right to dive deeper to get to that knowledge, right? So I I haven't used a lot of ai for this. I think for the tree, the python also has a module called ast, I think. So you can also pass it a string with code and it will build the, the ast, the, the tree, abstract, uh, syntax tree. Yeah, yeah, yeah, it will build the tree for you. So that also helps.

Rodrigo:

So I don't have to. I'm not, yeah, I'm not trying to invent the language, I'm just trying to mimic it and so I can also look at that tree. And so from the tree to the bytecode, it's a, it's a simpler jump than from the code to the bytecode. So I also try to mimic in some way that tree. And yeah, then I just Google if there's something I can't reverse, engineer or if I can't just figure it out. Because, again, since the objective is not to be production ready, to be production ready, I just cut corners a lot when, honestly, I don't care about whatever thing, whatever edge case was there, I just do it some other way. I simplify it for my own benefits. Yeah, so it's pretty standard, just googling. Okay, yeah, oh well, no, no, no, sorry, I, I forgot. There's this very effective method, which is banging my head against the wall. When something doesn't click, it tends to help it helps a lot.

Bob:

Yeah, yeah, it helps. Don't know what a headache, but yeah, all right, um, let's go one abstraction higher. Uh, maybe, uh, decorators and done their methods I mean, yeah, it's still an abstract and hire, although for some people they're pretty, uh, mind-blowing. So, yeah, very powerful tools in python. Um, sometimes underused, sometimes overly used, um, but you like them, I know right. Um, yeah, so do you have any favorite use cases examples? Where do you think uh decorators and dundas really shine and how do you have any favorite use cases examples? Where do you think decorators and dunders really shine and how do you use them?

Rodrigo:

All right. So one thing I really like, or the reason I really like dunder methods, is you've probably heard someone say that everything in Python is an object and this, what do you call it? The fact that this very, this standardization, or the fact that they're consistent, this consistency, that's the word I was looking for. This consistency has some brilliant side effects, and that's when the other methods come in. So you've seen integers being added. I mean, no one is surprised when they see their code 2 plus 2 equals 4. No one cares. But what you don't know is that, or what you don't necessarily see is that that addition, the plus sign, is actually calling a function behind the scenes. Or if you do something like if you check if an element is in a list with the keyword in, most people also don't bet an eye. That's a pretty standard feature. What maybe you don't know is that using the keyword in is actually calling a function with a funky looking name which underscore, underscore, contains underscore, underscore. But it's just a function call and uh, just in case you don't know the dunder, what it means or what it's short for, it stands for double underscore. So these methods, these, when you hear about dunder methods, they're regular methods. They're regular functions you can call them. It's just that they have two underscores in the beginning and of the name and two underscores at the end, and the way they look like that is just to make it harder for you to override them by mistake.

Rodrigo:

And there are methods that Python calls for you, and this is the I think this is the brilliance of it. Python calls those methods for you. It's documented how they work, when they're called, what they're expected to do, but Python calls them for you. So if you write, if you write, for example, your own container, and if you want your container to be able to work with the keyword in, you can do that. You can blend your object with the language, you can make it interact with the syntax. You just have to figure out that there's this Dunder method called contains that you need.

Rodrigo:

Or if you're implementing your own fractions, don't do that. There's already the module fraction. But if you're implementing your own fractions and you want to be able to use the arithmetic operators with them the plus, the minus, the times you just write the proper Dunder method so you can really create your custom classes, your custom objects. But then make sure they integrate nicely with the language, and I just find that very elegant because you can make it look seamless. I don't know if that makes sense for you. Yeah, it makes sense.

Bob:

I think the documentation is called the data model or something.

Rodrigo:

Yeah, it's the data model. But just open it and scroll to a random point and read what's in front of you documentation, and it's called the data model or something. Yeah, yeah, it's the data model. But just just open it and scroll to a random point and read what's in front of you.

Bob:

You're going to learn something new also like that fluent python starts right there, right, it's not explaining print and statements, it goes right into the data model in the first chapter and it's that's. That's. It's at its core, right? Um, it's also um a debated thing because, um, there are obvious things like, for example, the path lip. That's very elegant, right, like path, slash, path, and that then creates a new path, right, so it makes a lot of sense. But, uh, what was the dunder for that? If you, if you hold it, it's true div, it's true div, right. So that's kind of weird. But uh, yeah, it just goes to show like don't touch it. But if, if you hold it, it's true div, it's true div, right. So that's kind of weird.

Bob:

But yeah, it just goes to show, don't touch it. But if you want, because you have your custom classes, you can right. So you can go under the covers.

Rodrigo:

Yeah, well, you can also be creative, like you said. Yeah, the slash we typically think of it as division, but for paths it just really makes it look like we're putting paths together, so they're working with a method that's supposed to do an arithmetic operation, but then they're actually doing something else. Yes, you can write funky code, but for paths it makes sense. And there's other instances, other situations where you're actually kind of stealing a dunder method for something else, but it still looks. It still looks decent yeah, I will.

Bob:

Uh, yeah, that's not going to be done. The ore pipe anyway. Yeah, that was highly debated.

Rodrigo:

Um decorators then well then, decorators I've been thinking a lot about them because I'm I'm going to give a a tutorial at a conference in july at euro python euro python, yeah, yeah, at euro python, and I was thinking about them, and again, again, when I'm teaching something, it's not just about showing how to write the code with it.

Rodrigo:

I think if folks really understand the point, then it makes it easier for them to use it later, because even if you forget the small details or the actual syntax, if you remember the idea then you can recognize.

Rodrigo:

Okay, a decorator is what I should use here, and so I've been thinking a lot about them to try and find the best possible explanation of what decorators are for and why there's this at sign on top of your functions and stuff like that, and I think I'm I don't necessarily have the perfect explanation, but I'm really leaning on this idea that you use a decorator to create functionality that is orthogonal to the objective of your function, to the original objective of your function, because functions ideally do one thing and one thing only, and they do it well, right, and so if you have a function that crunches some numbers, then that's the purpose of that function.

Rodrigo:

But if you also want to say time the execution of the function, that's something reasonable. Or if you want to cache those computations because they're intensive and they're repeated, that's fairly reasonable, right, but you don't want to bake that into the function because then your function is doing too much yeah, you're polluting the function in a sense, right yeah, exactly, it's just going to be more code inside that function, which is not going to be the point of the function.

Rodrigo:

Yeah, so you just use decorators for that. There's a cache decorator in FuncTools. So that's the because this caching idea is a very reasonable idea. It's fairly general. You might want to cache very different functions and usually the caching itself is not the point of your function. Your function wants to crunch numbers or access some API or whatever, and so you use this decorator, you're decorating your function, you're adding more stuff to it, you're making it nicer, prettier with this functionality that is useful but also orthogonal to the original point and that makes it easier to reuse. The caching or the timing or the profiling or the logging or whatever makes it easier to reuse, makes it easier to maintain because things are separated, and I just, I just think it's a very nice idea just makes it easier to compose different building blocks yeah, no, I love it.

Bob:

Uh, yeah, I think it's also one of the classic design patterns. I should say we don't mix in other stuff in the functions that the function is up for, and we probably apply the decorator to a lot of functions, so we don't duplicate code as well. So it's a nicer way to keep it dry, or don't repeat yourself. Um, yeah, in that sense they could be called maybe enrichers or enrichers yourself. Yeah, basically, you're enriching uh functions, right, or okay, you can also use them on classes, I think. Um, yeah, you can, and the add is just syntactic sugar, right, I think it's just like it is a new function equals decorator and you pass the function into that callable, I guess. Yeah, yeah exactly.

Rodrigo:

So that's another. I'm not sure if you want to go there, if you want to go back to it, but that's another. For example, another side effect of everything being an object Functions are objects. You can pass functions to functions and that's how decorators work. But then what's a function? It's actually something that implements the Dunder method call. So if you create a custom class that implements the Dunder method call, then the instances of that class can be used or they'll look like functions because you can call them with parentheses. So it's not really about the functions, it's about the callable things. So it's not really about the actual it being a function or not, it's about behaviors. And then we could start talking about protocols, for example. Yeah, everything, everything is related. I just, I just love this. I have way too much fun with this stuff.

Bob:

Yeah, maybe we can do a follow-up on that on another episode. Yeah, more deep dive, you know. But yeah, I think you know understanding that everything is an object, hence we can pass functions around. I think that's important to understand, to grasp that grace, because I do think a lot of Python developers, especially when they're newer to the language, they struggle with really understanding decorators Because there's a couple of concepts coming together there, right, and this is one of them?

Bob:

Yeah, you're right. Oh cool. Well, good luck with that talk and probably highly needed. Yeah, thank you. Well, good luck with that talk and probably highly needed, Thank you. Talking about giving talks and conferences yeah, what is your approach to preparing Python talks or tutorials for people that want to do it for their first conference? Do you have any advice?

Rodrigo:

I do have some advice, and I think the most important piece of advice is to say that no advice really is very important, or very nothing is set in stone, or there's very few things that are set in stone. So you know, the stuff that works for me doesn't necessarily work for others, and I actually know good speakers that do the opposite of what I do in some aspects of preparing a talk. But what I do the most, or the most often the way I go about it is I pick the topic, which is usually either something I'm interested in or something I want to learn better. So, just going back to what you said in the beginning, if you have to teach, then you will be learning things properly, or you have to learn properly to be able to teach. So if there's something I want to teach, I try to submit a talk on the topic, because then I will have to understand that.

Bob:

And that's the main thing yeah, you're forced to move outside of your comfort zone.

Rodrigo:

Yeah, exactly yeah. So you pick the topic and then this might be. This might sound weird, but I just think about the topic for a long time. It's spread out over the span of multiple weeks. I just think about it. What are examples of, for example let's talk about decorators specifically. What are example use cases of decorators? Where have I seen decorators being used? What are real world applications that are easy to explain? You know how? Should I talk about classes being able to? Should I talk about the fact that you can decorate classes? What examples do I have?

Rodrigo:

So I just think about it in a very unstructured way, come up with examples and analogies and explanations, everything.

Rodrigo:

And when I have all of these ideas in my head, I write a blog post.

Rodrigo:

I write a blog post because it will allow me to pick the order in which I want to go through things, because a blog post is something linear, typically, and it also helps me make sure that these code examples work, because I'm actually writing the code, looking at it, running it, and Once I've written it, I have the, the base, the basic supports, the basic content for my talk, and then I just create slides.

Rodrigo:

Well, just quote, unquote, because that's also some work, but so my my main way of going about this is I don't typically script my talk very tightly. I just make sure I know the key ideas. I make sure that the slides convey those key ideas and then, because I spent so much time thinking about it and because I wrote about it, and hopefully because I rehearsed plenty of times, when I'm giving my talk I will always use different sentences from when I was rehearsing because, again, it's not scripted but that always hit the key ideas. So that's typically how I prepare, like a very high level overview of how I prepare a talk. This is more or less what I do. I've written about it as well so folks can check it later. But this is the the main way, or the main ideas that I go through.

Bob:

Yeah, nice, that's interesting. Sounds like a good approach. First, yeah, think about it, let it marinate. Unstructure, brainstorm I really like that you didn't write it as an article, because it's kind of a non-pressure way, but also where you can really structure it. Uh and yeah. And then the slides, of course, and if you have a good set of slides with a good repo, um, oh, you still have to overcome the stage fright, but I guess that uh comes with time. But you know the preparation is is 75 percent of it, I guess.

Rodrigo:

Yeah, maybe more than 75 percent, the preparation is is 75 of it, I guess. Yeah, maybe more than 75 percent, the preparation is almost all of it. I would say yeah, yeah, and then stage frights. I always get very stressed before the talk, like every single time, but then when I start it goes away.

Bob:

Yeah, yeah, no, it so yeah well, I mean the fact that you get stressed yeah, exactly that doesn't go but then when I start, it goes away yeah, no, so yeah. Well, I mean the fact that you get stressed every time that doesn't go away, but once you get in there a few minutes into it, right.

Julian:

I mean.

Bob:

I've not spoken at PyCon, to be honest, but of course I've been giving some talks in settings where there were a lot of people listening and it's like boom, boom, boom right.

Rodrigo:

Exactly.

Bob:

But once you're like one two minutes in.

Bob:

You kind of forget about it, and yeah it's funny how that works right, the human body as well yeah, it's a very interesting piece of technology the human body very advanced, incomprehensible, yeah, um, cool. So yeah, last two questions, because we're coming on time and and thanks for sharing all this, this, this great wisdom and experience. So, um, yeah, talking about conferences again, um, what's the most rewarding part for you? Attending those? Because you said at the start you're uh, you go to too many, right, and so, uh, yeah, I really like it, sorry, sorry, yeah, I, I really like it, sorry, sorry.

Rodrigo:

Yeah, I really really like it because there's this sense of community. If you go to enough conferences, or if you go to maybe the same one always in your country, if you show up enough, you'll see that there's a bunch of people that also show up regularly. A bunch of people that also show up regularly. And you see these folks that are volunteering their time to make the conference happen, and you see the organizers and you see the folks that go there just to hang out with each other and to learn stuff from each other. And to me it gives me some sense of belonging. You know, I have some friends that write Python. I have some friends that care about Python, but in a conference everyone cares about it in some way or another, and of course, some, and that's also fine.

Rodrigo:

I'm not judging Some. For some it's just a tool Sure, that's fine, that's what it's for. For others it's, I don't know, more than a tool, because it's where their friends are. You know, it surrounds the Python's where their friends are, it surrounds the Python language that their friends hang. And for me that's probably the most rewarding thing is meeting new people, interesting people, learning new stuff, but then actually getting to make friends. I like it a lot.

Bob:

Yeah, it's really nice to hang out with people with a similar passion. Right, and that whole community aspect, yeah, I agree, nothing beats that, I think. Quick break for a note of our sponsor this week, which is HiBytes, hibytes that's us.

Julian:

I'm here, Bob. What are we talking about this week?

Bob:

Well, we have a new coaching program PDC or PyBytes Developer Cohort. We thought it was never going to happen because we have been doing one to one for five years, but now we can do group coaching as well. We're going to build a real world app six weeks in an exciting cohort. We're going to learn with one of our PyBytes coaches the whole journey, but also work together and learn together. And yeah, no more tutorial, paralysis, build build, build.

Julian:

It's wonderful. It's not something you want to miss out on, so please check out the link below pybytescoachingcom. This is a program that bridges real building with a cohort, environment learning with other people, building with engineers. It's a wonderful thing. Check it out now.

Bob:

Now pybitescoachingcom, and back to the episode so the last question is what are you currently reading? Let's end with the books all right.

Rodrigo:

So I'm reading. I like reading fiction and currently I'm reading. I'm starting the game of thrones series. I've been ignoring it for too long, yeah. So yeah, I'm, I'm halfway. Then I'm halfway through the first book. I'm enjoying it. That's non-fiction, sorry, that's fiction. And then I'm a technical book I'm reading. I'm going through the Rust book, maybe for the third time, not in the sense that, sorry, I didn't complete it two times. I started it twice already, and this is the third time I'm starting. See if I can progress further into the book, because I really want to, you know, get a good understanding of how rust works. It looks like a very fun language. So, yeah, that's my technical read cool, uh.

Bob:

Is that the programming language, the one that's you can read online?

Rodrigo:

yeah, the rust book, basically, yeah, exactly, they call it the rust book, or someone calls it the rust book.

Bob:

Yeah, that's the one I'm talking about that's actually, uh, it's quite good, but I I remember the same thing. I I started it and at some point I get stuck, and maybe not because it's too difficult. Rust is not easy, but yeah anyway, but that's a good overview. And so what's their use case of Rust? Just general interest, or are you going to need it to build anything specific?

Rodrigo:

Yeah, no. So sadly I'm not going to build anything specific, just general interest. And I want to be able to teach it as well, because other folks have specific needs where they need speed, and Rust seems like a good option, so I want to be able to teach it properly.

Bob:

Yeah, it's very popular these days, right uh, by dantic and the whole tooling now being powered by rust.

Rodrigo:

Yeah, polar dantic and polars yeah, those big those. And astral doing all of their tooling in rust, yeah yeah, awesome and uh, the games of thrones.

Bob:

How many books is that?

Rodrigo:

I have no idea. Someone is is lending them to me. I'm borrowing it from someone else, so I'm just going to keep asking for the next one until they say, yeah, there's no more books. I don't know, it's plenty.

Bob:

Oh, it is a series and movie once. I kind of don't want to spoiler it. So, uh, I haven't watched the series yet. So yeah, I mean either. So yeah, spoiler it.

Rodrigo:

So, uh, I haven't watched the series yet, so yeah, me neither.

Bob:

So yeah, can probably first read the book. Great, uh, any final shout out um things to wrap up you mean?

Rodrigo:

you mean what self-promotion?

Bob:

that that surely uh is a good thing. Yeah, where should people reach out to you? And maybe other thing like yeah, final CTA. Or call to action for PyBytes audience here.

Rodrigo:

Ah, that's too tough. I forgot to prepare for that one. Well you can.

Bob:

The main thing is where can people find you? Where should they reach out to you?

Rodrigo:

Sure thing. So I Well. You can find me on my website or on my blog, so it's going to be mathspepcom slash blog. I write there a lot. You have plenty of stuff to read there if you want, and through there you'll find everything else I do which is too much.

Rodrigo:

And final call to action let's see, I do this very weird thing actually I haven't done it in a while, but I do this weird thing where I just open the documentation, the python documentation, and kind of randomly click through it to see where I land, because I always end up at a page that's going to teach me something new, and it's a very weird way to get exposed to new stuff, but it works because you get exposed to new stuff. So either do that to make sure you keep learning new stuff or, haha, self-promotion time. You can subscribe to a short daily newsletter that I write, where I send just a daily random drop of knowledge so that you keep getting exposed to these new things. Because python is a huge language and, with batteries included, you know it's it's a lot of stuff you can use and there's no way you know everything yet.

Bob:

So yeah, nice, I like that. Yeah, go read the docs, but then just randomly go somewhere and you'll find something, because it's, it's, it's humongous right and there's constantly new stuff being added, like look at the type hinting stuff. Right how much that has evolved right, and that's of course all wrapped in the docs. So, um, yeah, and then people go subscribe because uh, rodrigo sends a lot of uh cool tips, very bite-sized, so yeah thank you, wove well, cool.

Bob:

Thanks for hopping on. Uh, glad we finally got to do this and yeah, again thanks for sharing.

Rodrigo:

Thank you, it was a pleasure to be here.

Julian:

Hey everyone. Thanks for tuning into the PyBytes podcast. I really hope you enjoyed it. A quick message from me and Bob before you go To get the most out of your experience with PyBytes including learning more Python, engaging with other developers, learning about our guests, discussing these podcast episodes, and much, much more please join our community at pybytescircleso. The link is on the screen if you're watching this on YouTube and it's in the show notes for everyone else. When you join, make sure you introduce yourself, engage with myself and Bob and the many other developers in the community. It's one of the greatest things you can do to expand your knowledge and reach and network as a Python developer. We'll see you in the next episode and we will see you in the community.