
Pybites Podcast
The Pybites Podcast is a podcast about Python Development, Career and Mindset skills.
Hosted by the Co-Founders, Bob Belderbos and Julian Sequeira, this podcast is for anyone interested in Python and looking for tips, tricks and concepts related to Career + Mindset.
For more information on Pybites, visit us at https://pybit.es and connect with us on LinkedIn:
Julian: https://www.linkedin.com/in/juliansequeira/
Bob: https://www.linkedin.com/in/bbelderbos/
Pybites Podcast
#196: Robin Quintero on Complexipy
In this episode, we talk with Robin Quintero, creator of Complexipy —an ultra-fast cognitive complexity analyzer for Python code, powered by Rust.
Robin shares how frustration with slow tooling led him to build Complexipy in Rust, how it's helping Python devs write clearer code, and why teams are loving it for faster, cleaner pull requests. We also dig into the future of the project—from multi-language support to AI-powered refactoring.
Check out Robin's latest updates on his socials:
https://www.linkedin.com/in/robin-hafid/
https://x.com/hafitoalimania
https://github.com/rohaquinlop
And find out more about Complexipy here:
Docs: https://rohaquinlop.github.io/complexipy/
Cognitive complexity paper: https://www.sonarsource.com/resources/cognitive-complexity/
Want to know what we're reading? Check out the following links:
Rust book: https://doc.rust-lang.org/book/
Creating an AI model to refactor code to reduce cognitive complexity (in Spanish): https://x.com/hafitoalimania/status/1934063600450044061
___
💡🧑💻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
Spotify: https://open.spotify.com/show/1sJnriPKKVgPIX7UU9PIN1
I really trust the Jan Campbell work and I know that if Complexify starts to grow because there is an issue related to focus on more languages it could be interesting to have a metric to help more developers.
Julian:Hello and welcome to the PyBytes podcast, where we talk about Python career and mindset. We're your hosts. I'm Julian.
Bob:Sequeira, and I am Bob Veldables. 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, and I'm here with Robin Quintero. Robin, welcome to the show. How are you doing?
Robin:Thank you. Thank you for the invitation.
Bob:Yeah, I wanted to have you on the show because I learned about this tool. You wrote Complexify, and I first learned about it on the Python Bytes show and Brian Ocken mentioned it. So I looked into it and not only is it a cool code quality tool, it's also something I think, a nice example where you wrote it in Rust and then integrated it into Python. Right, yeah, but before diving into it, maybe you want to introduce yourself to the audience and tell us a bit about your background, and if you have a win of the week, then feel free to share it as well.
Robin:Okay, my name is Robin. As you mentioned, I'm from Colombia, I live in Palmira and, yeah, I have been doing open source since I don't know. Like three years ago I started creating automaton, which was a Python library to help students and research to simulate and visualize uh, python, uh, automata Now those from CS theory. I really like it and try to implement it. I didn't, I just dropped the support to the library I'm not interested enough on this topic but I really like it and that was my introduce to open source creating tools for the rest of the people, help them. So, yeah, basically it was that I used to program on CMC++ and when I started to code in Python, I really enjoyed the syntax, but the performance I just don't like it because I come from faster languages and that's when UV, this tool from Astral SH, started to get really popular. I started to follow their work when they just started to to code it and I really like it that they could like implement this really fast tool with a compiled language which is rust.
Robin:I uh like reading a lot and at that moment I created a PR to to the Rosland uh so a project and got I said so for me. That was amazing. Right, I contribution to a huge project, but I haven't used it yet on a project for me. So I was thinking like, oh, what could I do to start to create with this language? And then I had a task to. I had to reduce the cognitive complexity of a code base where I used to work. And the thing here is that the process was really slow. Using the VS Code extension was really painful because if I wanted to save a file, it took like 10 minutes, something like that, because this extension do a huge work in the background. So I started to read like what's cognitive complexity? How does this measures, this metric? And that's when I met the Sonar paper white paper, which is created by Gian Campbell this is the primary author of the library Campbell, this is the primary author of the library.
Robin:And, yeah, I started to read and wanted to implement something to make it fast, because my process was really slow. I had to create a PR, push it, wait to the pipelines, then I had to wait to sooner uh repo and then check the. The. The metric was really slow, like two hours to just check one change. And I said to to Dick like, huh, how could I implement this and then I I found that basically you can check the AST, the Python AST abstract syntax tree, and play with it.
Robin:And as I was interested in creating a project and also with the formal basis of a programming language, I started to create Complexify. I started to create Complexify the really basic version just a scan of the file and output these values with their function name. And that was fast, because it took like less than one second to analyze and I started to work on this analyze. And I started to work on this. I wrote to Jeanne Campbell primarily thanks to her because her investigation was really important All my project is based on what she published and also to let her know that I created a tool based on that.
Robin:The Python Sonar team I think that's the lead started the repo on the first version that I published on Reddit. So for me that was amazing right, and since then I have been working on Complexify more regular because there are open issues, some mentions, as you said, this podcast mention was really important for me because I started to receive a bunch of stars and I said someone mentioned Complexify, because this is enormous, because this is normal and the space that they dedicated also was as special as you are doing, because you are giving me a, a space for you, for me in in your podcast. So that's that's how uh complexify was created and more or less that's amazing, thank you.
Bob:Also the fact you had the PR on the Rust language. That's massive. But yeah, I have a couple of follow-up questions. So we're going to link this paper, of course, because just going back to software complexity, and we have like cyclomatic complexity MacGabe right which I think has been part of Flake 8 for forever, right, I think that was invented in the 70s. But then now you have cognitive complexity and in the paper, I think in the first pages, you see this nice example where I think it was a match case statement and then there's like a double for with a kind of a go-to thing to go to the outer for loop and that then gets complexity four right, both of them with mcgape, which obviously the inner four with a go-to construct is way more complex.
Bob:um, so the cognitive it's just a better way of of calculating the uh complex, because I think if you use that one then the case matches really just one match case and the double forward goto is like seven, right? So is that kind of it's just a better way to calculate the complexity, right?
Robin:Yeah, it's focused on developer side, because this is a metric to measure on understandability and sustainability, because when you code, you're not coding most of the time just for yourself, right? You are collaborating with other team members and so on, and when you are creating code you must make sure that that will be really easy to understand and to maintain because during the time there will be a lot of modifications and the metric also tries to have this in account to make some penalties when you leave open the gate to let the programmer start to do a messy stuff. The match statement that we have in Python is really powerful. It's like the match statement on so many powerful uh by uh, uh functional programming languages that are existing. Right, you have these match to make with different classes, name the attributes and operate with them.
Robin:This match statement makes it really easy to understand the code because you know how will the variable have these changes during the time and the metric tries to make penalties because in an if statement you don't have just one variable as you have in the match. You can start to binary operations operators sorry and start to make it grow and grow and grow and make it harder to read. But the match statement, not just one that are the attributes of the, the variable that you are using, or a tuple, something like that. But this metric I feel that's really focused on maintainability and I have um proven myself that it. This is true because most of the PRs that I do at work, if I focus them using the complexity plane, get approved faster because they are really easy to understand. But if not, there are a lot of comments to refactor things.
Robin:So you can start to notice that, this sense of maintainability, I start to be really close to cognitive complexity and good practices, not just having a function that says process, but that one isn't only processing things, that one is pulling data, then it's moving or operating with those data, changing the values, and then it starts to process. You can notice that these steps that are not processing, you can create a function with them and then that will be really easy, like just have the assignment and you know that that variable, have something assigned and then you operate with them in the function. It's really related to the SOLID principles single responsibility, you can notice and so on. So I really trust the Jan Campbell work. I know that if Complexify starts to grow, because there is an issue related to focus on more languages, it could be interesting to have a metric to help more developers Right, not just the Python.
Bob:Yeah, and I like the thing you said at the start. We often write code for other developers to maintain right, so it's something to keep in mind. So about the implementation on Rust you had, the paper, bust is just following the rules in the paper and building it from scratch in Rust.
Robin:Yes, and I tried to create in the past some extensions to Python using C or C++, but they were painful, really, really painful, because if you want to start to create, you have to create a lot of files and then create these dependencies, all of that and not like you just install something, run a command and then start to code. So I really love it that from Rust because Rust have this primary library name but Maturin. Maturin what does is basically give you that you can run Maturin develop and then it sync all the Python files with the Rust implementation. So you just focus on develop, write code and so on, and with Rust the Rust implementation for this was really faster. I had the first version in just like one month, something like that Usual, like not just values and so on, but computing the values right and that. And what I liked is that Rust sorry have this web assembly where you can export code, but not just Python but JS, so JavaScript currently have the original implementation for the extension of the VS Code.
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, pybitesplatformcom. And back to the episode.
Bob:And right now you only support Python right.
Robin:Yeah, by the moment, I haven't written the, because for Python we have the AST, but for other languages we should have something like a tag or something like that using tree seeder, and that's why I haven't started, because it sounds like a boring task.
Bob:But so so. So there's the AST module in in Python right Standard library and the library uses Rust has an equivalent to that.
Robin:Yes, in Rust I'm using the one used by roof, that's created by the Astral SH, and I use it because that's better the old one that exists in in Rust at cargo. Um, it's basically duplicated. You can support the new language versions, while the one created by the Astral team just do it. So, basically, that's why I updated the library to do that.
Bob:Cool. Were there any challenges? Because, yeah, the PIO3 thing is amazing. We had David hewitt on the podcast as well, core maintainer, uh. But were there any? Um, because I I looked at the code and and the python is mostly like the cli, right, I'm not sure if you use typer, but that's, that's mostly it, and then you just import the uh, the converted uh yeah, you know uh, yeah, converted in a sense Rust callables or whatever. Right, yeah, the Python is a very thin wrapper. Was there any challenges with that integration?
Robin:Mainly, focused on the Rust syntax and Rust usage because at the moment I didn't have the expertise that I currently have with Rust. So there were a lot of bad code or bad practices that I had and I know that they are still present on the code because of my expertise like an expert place but also the the complexity by implements parallelism to to process files faster. So, as you know, the Python have these G global interpreter log. So there are a couple of things that you must do on the Rust implementation to let you use real parallelism, because if not that would be really really slow. So that was a huge challenge to implement it. But, as you say, python works as the cli and then I try to use basically all in rust because it's faster and I want to give that feel to the users that it's really fast. I don't like slow tools. I must implement them fast Because if not that would be bad.
Bob:But yeah, yeah, I think sometimes at speed we think we don't really need it until you have it in the tools and you think like, oh, actually I didn't realize that things were so slow in the tools. And you think like, oh, actually I, I didn't realize that that things were so slow, right, I remember rough rough came out and and on the podcast they were saying like, uh, oh, it just linted my whole um code base of 200 files and in a blink of an eye I was even running it again because I wasn't sure if it even did the job. It was so fast, right. So yeah, yeah I.
Robin:I had this uh issue in the past with the type checkers that are in Python. I didn't like them because if you want to save, they are really slow, or type check, and I tried to create a new tool doing this type checking. But this is an easy task because type theory is huge, is like a whole new universe. But I applied to astral in the past to work there with this idea but they like I I'm not a like professional that they have in their team, so I just got rejected. But I saw recently that they are currently working in a type checker. I know that that will be a game changer for us because type checkers are really slow, really, really slow. So these guys are amazing and I know that they will complete this task, this task yeah, ty right, yeah, it's a massive effort, a lot of yeah yeah cool.
Bob:So, uh, yeah, how's the adoption been? I uh, what I really like in the documentation. You have examples to hook up your tool with, get up actions. You can use it with pre-commit, so it's all very well documented, fast, nice output. So, yeah, how has the adoption been and what are some extra features you're working, or are the core rules implemented, and that's mostly static.
Robin:Yeah, the adoption. I just created a Reddit post for the very first version. There were a lot of comments. Some people love it. Other people wanted me to sell them to use cognitive complexity. That's really weird. I don't know why people ask it, but most of the people use it. I know that they use it because there are a lot of like a lot two or three papers related to it, using Complexify to develop LLMs models. So I know that if I have created this library a year ago and now have paper mentions, that's because it's important, right, and it's like I don't know how to say it. But most of the people that use it start to recommend it because I start to see stars on Reddit and GitHub and see how they start to create issues. So that's amazing.
Robin:I can remember the other question, ah, the features. I want to implement or improve the VS Code extension, because that's really basic. I created a new release with like a couple of hints to reduce the cognitive complexity and recently I was trying to create a AI model to refactor code to AI model to refactor code to reduce the cognitive complexity. But the most hard thing is the data set, because I need a cognitive complexity code with a high score and then write the solution like the solution, the, the reduce to reduce those complex complexities. So that's the hard task, but the very, very first version worked. I have a clip of it working. I don't know if you want me to to send you that.
Bob:You can definitely link that. That would be cool. Okay, perfect.
Robin:And yeah, that's like I have in mind, because cognitive complexity it's really recent, if you see. It's like 2022, something like that. So the changes basically are related to what the primary author do and what I consider, and here are a couple of updates on the repo. I recently noticed that we have the with statement, but I didn't cover that case because the with statement it's not just like write a variable Under the hood. It have the finally to close the object. All of this is a stuff that it's not considered or explicit on the paper, but you have to start to think about it. So that's basically how the, the features, will change.
Bob:If I've noticed something is if someone mentions something on the issues, I have to work on it yeah, that's a good point because, yeah, I guess 80 aesthetic like the fours and the ifs and just just basic language concepts. But yeah, python also comes out with new features. Right, like uh, match case, as mentioned, that was not there till 3.10, right, so they come out with new syntax and you all have to write new rules, right.
Robin:Yeah, I try to answer most of the questions as fast as I can, and contribution isn't only like writing code, but create an issue. Say that you just put in something. I didn't know that the library has a bug for Windows OS, so it ran in Linux, mac, but Windows was not working, mac but Windows was not working, and someone mentioned it, and recently I work on it because that one was an easy task to do. But, as you can see, you can contribute to your project, not only like hey, I have this code, which is great, but if you don't do that, you can create an issue. And that will be helpful too, because you are basically testing the library and helping me to improve it.
Bob:Yeah, that's a good point. It's not only about coding, but also like testing and brainstorming, documenting.
Robin:Exactly.
Bob:GitHub is great for that. So, yeah, we'll of course link it and yeah, yeah, people should go check it out, not only use it, but, uh, yeah, maybe also go into the guts. Of course, it requires the rust because, that's where the core is written in. But uh, yeah, there's definitely uh some people in our community that want to learn it, and so uh, yeah, and it's a trend right More Rust and Python these days. So yeah. Uv Astral.
Robin:Yeah, most of these new tools focus on performance and you can say that Python is slow for some tasks, but you have Rust which can help you with those pain points. So I think that's the future not not uh leaving python, but using python uh, with help of other languages focused on performance.
Bob:so, yeah, do you have any tips for learning rest because you come from a, c, c plus plus background, so that might be an advantage. It already had that mindset, compiled language. But people don't have that right and they they mostly have python or scripting background. Um, what?
Robin:would you recommend? I really really love the rust handbook that they have. The documentation that they have for Rust is really easy to understand. You can learn the complex I don't know how to say that the complex features of Rust with this handbook Explain it. You have examples so you can run it on your computer and you can start to understand. Why is it like memory safe where it comes right, because you can hear it, but where do you notice? It's memory safe and I can say that it's more related to the functional programming paradigm, like this mental applied to memory how it will start to reallocate when a function moves a memory, like a space, as a string. Let's say how it will start to do things right, how this is safe, why is it safe? And you can learn a lot from the handbook.
Bob:Is it safe and you can learn a lot from the handbook. Is that what they call the Rust programming book? That's just the official book online.
Robin:Yeah, exactly yeah that's the official one. You go to the Rust webpage and then you have this button with the documentation. Click it and read it.
Bob:Yeah, no, definitely accessible. I think the big thing is the ownership model and moving copies that might be hard for us Pythonistas to wrap our heads around.
Robin:Yeah, but the documentation is easy.
Bob:It's all abstracted away in Python, right yeah?
Julian:Hey everyone, a quick break from the episode to introduce you to our brand new coaching program, the PyBytes Developer Cohorts. Now, these are cohort programs typical of a boot camp style interface, of working together with a group of other people, except it's got that unique PyBytes twist on it where you are going to be building all day, every day. There is very little material that you will be consuming, so you won't be stuck in that tutorial paralysis. The point here is that you will be building from day one and alongside other people also building the same app in their own repositories. You can all talk, you can all share, you can all grow together and, of course, you'll have a PyBytes coach supporting you the whole way. So if you are interested, just check it out, click the link below. It is piebitescoachingcom and we will see you in the next cohort uh, last question um what are you reading?
Bob:any book tips?
Robin:honestly, I'm not a like of reading too much, but at the bacon, someone uh recommend refactoring B, which could be related to to complexify, and I will read it. I already have it on Amazon. I still thinking if I should order or not, because I'm not of reading too much. I'm most of doing right, but I I should start to read. That's that's why, uh, that's what I will be reading.
Bob:Nice, the classic right, the Martin Fowler.
Robin:Yeah, yeah, exactly that, that, that one, I haven't read it, yeah definitely related to what you're doing.
Bob:Okay, perfect Refactoring to keep the complexity low, yeah, lower, yeah, cool. Well, thanks for sharing Really amazing stuff you're working on and I will link it and we'll share it in the community so people can check it out.
Robin:Any final shout out or uh, yeah, piece of advice, um, you can use complex supply really fast and really easy, like I have working um uh, this GitHub action so you can add it to your pipeline, so the developers don't start to add uh more complex to it to your pipeline. So the developers decide to add a more complex to your code and if not, you can use the pre-commit or install it locally and run it every time you want it, or use the VS code extension, because that one is locally too. But you have these visual insights that what lines are adding more complexity and also my function how complex is to understand. So that's all from me.
Bob:Yeah, I like how you have all these interfaces into it, because you can.
Robin:You have all these integrations, but then you can also use it as a command line app and you can even like import it in your Python code and just run the functions directly, right, exactly that one is more focused on research because most of the time they they need to like run it, check the, the model output and then do more stuff, so that one, a, an user, created that feature. I really like it because they or him pushed the, the, these changes, both with the code already implement or everything working, and I was great yeah and uh, they already have a next language lined up.
Bob:You would add, or you just keep it Python for now.
Robin:I want to implement to JavaScript, because that one is a very, very used language, and the thing here is that to implement it I will need to create or use three-seater and have like a mental way to apply to this case Any new language that will be using three-seater. Apply these new rules to create, let's say, like a doc or a tree for my class, for my project too, and I start to apply those functions to every language. That's why I'm thinking that's hard, because if not, they will just search and apply, just focus on the language. But I want it to be general, I want it to be like okay, we have it. Be like okay, we have it. But if, with this work done, we should cover most of the language, programming languages, so that's why it's a boring task, because I have to find this way to do it and, as I am not really really interested in into doing it, that's why it sounds like boring.
Bob:yeah but I have to do it. That's a challenge right like, and you would yeah, and maybe ask yourself like would I do it in the same tool, in the same repo? Maybe you make like a sister repo, but then would it lead to duplicate code.
Robin:That's that's the challenge yeah, yeah, yeah oh, awesome, and from that I think complexity then shouldn't be just on pi p to to install it. I should start to think like, okay, we should use brew or something like that, and that's a lot of work but yeah, yeah, oh, you got the pie in the name as well exactly exactly well awesome.
Bob:Well, thanks so much for hopping on and sharing uh, really inspiring and uh, yeah, keep up the great work and hopefully, uh, let's get some more eyes on it and maybe people contributing.
Robin:That would be great yeah, that would be amazing. Also, thank you for for having me here. Hopefully anyone that hears this start to contribute to Complexify and if not, you can start to use Rust in your work. I have tried to implement some optimizations at work and I can notice like 20 times faster than the original implementation. That's amazing. That's cost to reduce, so you should try it awesome.
Bob:I think people are convinced. Yeah, all right, thanks, rohan. Thank you hey everyone.
Julian:Thanks for tuning into the pie bites 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.