- Podcasts
- The Python Show
- 37 - SQLAlchemy, Databases and Python
About this episodeEpisode 37 of The Python Show Podcast has special guest Mike Bayer, the creator of SQLAlchemy, Mako, and Alembic. In this episode, we…
Episode 37 of The Python Show Podcast has special guest Mike Bayer, the creator of SQLAlchemy, Mako, and Alembic.
In this episode, we discuss the following topics:
* Python packages
* The origin of SQLAlchemy and Mako
* How databases have changed over the years
* ORMs in Python and other languages
* and much more!
Additional Info
Want to learn more about our guest, Mike Bayer? Check out the links below:
* Bayer’s website
* Bayer on GitHub
* Bayer on LinkedIn
* Bayer on Twitter / X
* Mouse vs Python - PyDev of the Week: Mike Bayer
The Python Show is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.
Get full access to The Python Show at www.pythonshow.com/subscribe
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
37 - SQLAlchemy, Databases and Python
so uh mike is the creator i think of sequel alchemy maybe with some other people as well as a couple of other libraries you may have heard of like mako and olympic i think i pronounced that right yeah you did yeah sometimes mako people want to say mako but it's okay mako as far as i know it's named after a shark oh cool There's a story there, but yeah. Actually, let's just talk about that. That'd be cool. Tell me how that came about.
The reason Mako is named Mako is because I was trying to target an existing Python template language called Cheetah, which is also named after a fast animal, like a fast, ferocious animal. So I wanted to find another fast, ferocious animal that wasn't like a cat. So we used a Mako shark, which I think I looked it up. It was like the fastest shark.
something like that there's the story of a big oh i was thinking it was some japanese thing but that's that's fun yeah it's a shark you know you can google it and uh you know that's cool all right i don't normally start out with like with that kind of a question but normally i ask about how you get it got into programming so let's yeah let's back up and talk about that a little bit yeah well i'm uh
I'm Gen X, so I'm from the 80s was when I got into programming. If you were a kid before 1980, you probably didn't do any programming because there really weren't computers accessible to people that didn't work at like Xerox PARC or something like that. My dad bought a computer called the TRS-80. which is apparently it's known in America, but other countries it's not as well known. It was made by this company called Radio Shack that we all used to go to to buy our electronic parts. So in about 1980, I had a TRS-80 and we also got one at school at the same time. And I got chummy with other very, very few kids in the school that were interested in this computer that was like in the library. It was this weird thing. And, you know, the TRS-80 had like early Microsoft Basic. And, you know, if you were that kind of kid and you wanted to do that instead of playing hockey, like everyone else in my school, you know, you were there, you know, writing little basic programs, line numbers, GoTo and GoSub were kind of the basic system of calling things, you know. And then my dad was also kind of a technical guy. He bought a TRS-80 Model 2, which was this really obscure computer that was more business. And he wrote like his own accounting software. And I used to hang out with my dad doing programming. And, you know, and my dream computer, I was going to either be an Apple II or a Commodore 64 or an Atari 800. And I got Atari 800. So when I was 16, which is maybe the mid 80s, I was writing assembly language software. on the Atari, which was a thing that a lot of people were doing. Well, if you want to write games, that's how games were done on the Atari 2600, you know, they wrote, you couldn't do a C compiler on these things. They're tiny. So I didn't, I wasn't successful. I mean, I spent like years writing like the title screen, you know, that's all I did, but I was able to make, you know, graphic effects, the sound, you know, uh yeah and then and then after that you know the late 80s ibm pc architecture came out and then computers were kind of i guess kind of democratized at that point because everyone everything was either everything was either an early mac or an ibm pc and yeah we were in the pc world because macs were very expensive uh you know and by then computers became a little more common and i took ap computer science in high school and I majored in some computer stuff in college, although I didn't graduate at all, actually. Oh, wow. Yeah, yeah.
I bounced around college because I wanted to be a musician. So I was bouncing around between engineering school. I went to BU my first year for electrical engineering. And, uh, I went to SUNY Stony Brook, which is my hometown, uh, for engineering. Uh, and I also went to Berkeley college of music and I just kept bouncing around and then I just kind of moved to New York city and, you know, kind of moved to New York just to kind of be, I figured I would do some computer stuff, but be a musician. And then, um, the internet industry started in like, you know, 1993, 1994. Yeah. And, uh, then it was like the entire world just changed, you know, because before the internet was a thing that you could get employed, you know, programming was pretty dry. Uh, it was like visual basic at like law firms and stuff like that. And, uh, The internet was like, wow, could you write two lines of code? Let's pay you all this money. The original dot-com boom was a really tremendous big deal. So that's how that all happened. It wasn't a planned career. It wasn't like, I love computers and I'm going to be a programmer. It was like, no, I really don't want to do programming.
don't want to be a drummer but then once the dot-com thing happens you know okay i guess this is okay yeah i hear you yeah yeah yeah i originally wanted it to be i do video games but i didn't realize it required not just computer programming but all this art related stuff too and i'm like i'm not really good at art
Right. Well, nowadays, you'd have an art staff to do the art for you. But yeah, I was doing like 8-bit designs of characters and spaceships in my teenage years. But yeah, to go from those vague ideas to like a game was like, it was insurmountable. The people that wrote games in assembly language, I can't imagine. Even today, I don't know how they did that. How could you possibly do that?
I think assembly, though, it was simpler in those times because we were doing assembly on 8-bit processors. And once I took some assembly language stuff in college that was more about like 6,000, 8,000 chips or pre-Intel, it was the opcodes and the way the address spaces were up was much more crazy and complicated.
Well, I think when I was doing my programming career, we started with Pearl, you know, that was the main thing we used. And then I got really into Java, you know, because I was programming for my job. So Java was a big deal. Um, when I did Pearl, I really liked to try to do object oriented Pearl, which was kind of not popular. Like Pearl had some object oriented features because I really kind of liked object oriented. I kind of liked a lot of, there's a lot of things about Java that I found to be that I liked. I liked the objects. When I first went to college and I went to Stony Brook, we actually took an object-oriented course. The main CS301 was using this new technology called object-oriented programming. And we learned this language called Modula 3, which was a very early object language. And I got into it. So I kind of like the Java object oriented thing a lot. So with Perl, I was always trying to make Perl do, and Perl did object. Perl 5 had an object language, but nobody liked it. And everyone was like, you know, all these Perl, you know, purist people were like, don't you do that object. You know, it was like, you know, so there's all this cultural crap. So I kept thinking, where is there a language that's not as heavy as Java? I want a scripting language. And I like that Perl has dynamic typing. I didn't like that Perl has weak typing. Now, weak typing, people listening, means that if you have a string with an integer one, that could be the number one or a string one. That's weak typing. You don't know if it's a string or a number. But dynamic typing means a variable can have different kinds of data in it. I like that part of it. And I wanted it to be scripting me. I could just write code in a file and it runs. And there's not a big fanfare of all the Java jar file stuff and everything. There's not all this stuff going on. And yeah, I wanted the object feature. So Python seemed to have that, but I was like, it doesn't use brackets, you know? And I was like, kind of for years, I was like, boy, I wish that Python had brackets because I'm not going to bother learning it. But in white space, it's what a stupid, like, you know, you see people even today, I just a few days ago, I saw comments on like hacker news, like, oh, Python's a non-starter because the white space like really? Like today, things are different today. Yeah, but I got into it anyway. I was working for Major League Baseball for their website. It's a separate company called MLB.com. And they're still there, obviously. And we wrote a whole CMS in Perl. And there was something we were doing where we were using CVS. So back to, this is 2003. Version control was still CVS. If you were doing open source, SVN was kind of coming on the scene. There was no Git or material. I don't think 2003. So we were using CVS for some kind of publishing thing. Like people like baseball editors could write some word files and they could send them to this web page or something. And we would store them in CVS to version them. And we wanted to give them a front end to the versioning system. And there was some program called WinCVS. That was a Windows client for CVS.
That was it. It was like, okay, I'll learn this stupid... white space thing, you know, and, um, you know, that was it. We wrote a few, I wrote a few macros for when CVS I had to learn. you know, about two hours worth of Python. And I was like, oh, this is great. And what I really loved about it that was different than Perl was that when you make any kind of symbol in your Python program, everything is the same object. Like if you import a module, that's actually just a variable name that's an object. the module object. And that, because with Perl, what always confused the crap out of me was that it was always like use name, colon, colon, name, colon, colon, name. And there was this whole thing about globs. And I never, and I was, even though I was pretty good at Perl, I never understood the whole import namespace. It just never made sense. It was always these magic stars and dollar signs. And, you know, I kind of knew how to do what I needed, but I, you know, I did Perl for like seven years. I never understood Perl. what any of that was, why if I import this here and that over there, it doesn't work. And Python's like, oh, everything is the same object. And you can actually have import cycles, which are inconvenient. But to me, they make sense. Like you've imported this, then it ran this, then it ran that. I thought it was very... Just the imperative nature of it was like, wow, that's cool. I totally get this. And I found that to be the way in Python, every single thing is a first class functions, lambdas. Everything is an object. Everything you can look at, you go to PDB and look at it. It's all either a dunder dick or a dunder name. That's like it. I had never seen that in any language. Like Java certainly doesn't have any runs. I mean, I guess Java has runtime introspection, but it was very primitive when I did Java and you can't just, you know, maybe you can now, but back then you couldn't just like PDD and that's all your Java options. You can eco poke around. That wasn't like that, that straight phone. It certainly wasn't. And also a Pearl, it was, they had debuggers also, but like it was not, Python was the first language besides C because C had nice debuggers in like Microsoft Visual Studio that I actually could do real debugging and that's print statements.
So yeah, I got into Python and I'm like, okay, now I've got to make my, you know, like your toolbox. Like you're going to get, I figured I'm going to, I'm going to get jobs doing Python because I can also, I mentioned at the same time that Python, you know, at that time, Ruby was also coming out. Ruby on reps was also becoming popular like 2004. Yeah. And I thought Ruby on Rails looked terrible. And I thought Ruby looked a lot like Perl with less features and stupider choices. And I just got a really bad vibe from Ruby and Rails. And I was just really, really not into that entire scene. at all because it looked like another let's go crazy with dollar signs and crazy syntax and threads. Who cares? Who needs that? We don't know what we're doing. It just seemed very amateur to me. And Python looked really smart. So I'm like, I got to get into Python and I have to help make this language popular because I do not want the job market to be all Ruby on Rails and PHP. I was like, no way. I'd rather be doing Python if we're going to have a scripting language. So I tried to build web frameworks and I tried to port... Well, I did. I ported a Perl framework called HTML Mason to Python and it was awful. It was called Mighty and it was pretty bad. It took me a long time. It took me a long time to get good at Python and also to even understand... what it means to be idiomatic in a language. You know, like it used to be back then you switch languages and whenever, whenever you switch a language, you would try to do all the patterns you did in the other language in a new language. Well, I just want to make, I want it to work the same way as it did before, you know, and there was really, you know, there wasn't like as much of an ecosystem of soft, you know, we didn't have like Google really, we didn't have this whole programming community, like the whole idea that when you learn a new language, you really need to spend time learning the idiomatic patterns that i didn't know that like i sort of knew it but it wasn't like a thing that i said i had to spend time making sure i read lots of good python and learn what it looks like yeah you know and even back then it was python 2.3 so a lot of the python features we take for granted didn't even exist back then anyway um yeah so i wrote the web framework and then i hated the web framework and i wrote sql alchemy because i basically had been writing those object database patterns in Perl and in Java and even in C++ a long time ago and in C. I'd written the same, make a query, get some kind of object back, make the object, do some kind of an insert statement. I've been doing that code over and over and over again for 10 years already. And I had used every vendor database or what I'd used. I'd used MySQL, I'd used Oracle, I'd used Sybase, SQL, earlier SQL servers, a precursor to MySQL called MSQL. I'd used Postgres. And it's like, I'd worked with all the databases, like not all, but like, you know, the really major ones. Yeah. I had witnessed all the pain. I'd written ODBC code in C. You know, I did Oracle, some OCI, you know. you know this is all before the python so it's like yeah i'm gonna make a library that's gonna abstract this stuff away which is what i do anyway but i'm gonna make i'm gonna this is gonna be the library to to finally end the discussion yeah you know so sequel hockey wasn't the first orm i wrote it was like the fifth or sixth you know okay okay
Yeah, that was the time that SQL Object was out. And I looked at SQL Object, and I actually did take some ideas from SQL Object. SQL Object is an active record type of ORM. So you have your object. And if you want to make an insert, you say object.save. And if you want to, object.delete. I forgot what its querying paradigm was, but I really wanted something that had some degree of separation between the way you write a select statement and the way you get objects back. Because when I worked at MLB, we, you know, we worked on a gigantic Oracle database that was on like one of these old school Sun microsystems, giant refrigerator systems. console cabinet things. And it was Oracle and it was like a beast. And we were querying from views that if you ever joined a view, it was bad. So we needed to be able to write very, very flexible select statements that could join and union all over the place, pull all kinds of rows from everywhere in as few round trips as possible and give you a graph of objects. So I knew that I did not want to have it be like, query for the X object, query for the customer object, query for the article object. It's got to be, no, it's got to be anything. And I've got to be able to get my art, my objects from any kind of query or review. So it needed to have a big indirection ladder between how you get objects back and how you query. And so SQL object didn't have that. And when I did it for SQL alchemy, I actually didn't do it right anyway. Originally people that use SQL alchemy probably know, there's this object that you don't really use publicly too much called the mapper. Like when you map a class, there's an object called mapper. Originally, the mapper was the public interface to query it. So I had originally thought you'd make different mappers for your object. If you wanted this kind of query, you'd make one kind of mapper. And if you wanted a different kind of query, you'd make a different kind of mapper for the same class. And that's not how it turned out at all. But... that was the basic thing that I was trying to do. Um, and what I took from SQL object, um, was the way, uh, I believe Ian Bicking wrote the original SQL object. It overloaded Python operators to create SQL expressions. So, and that's a really common thing nowadays. And it was started by SQL object and then it was probably popularized by SQL alchemy. And not everyone does that, but the idea that you can have X and then you do double equals Y, um, And it's not a Boolean that actually creates this other object that's like a SQL where clause type of thing. I took that from SQL Object completely, you know, and I've always said that. And that's how we did it. That's how we wrote the, you know, the expression language in SQL Login was based on overloading Python operators. and then also putting a namespace. SQL Object had, like, if you had a class that you mapped, there was, like, a namespace. I think it was, like, myclass.q.columnname, something like that. So I named it .c, but I put it on this other object called a table, which represents a relational database table. Yeah. So originally in SQL Alchemy, you would write queries using core tables and selects, and then there's kind of a translation that would... You know, like you make a mapper against that select and you get back your objects. And that's how it works. And then at some point very early on, someone said, hey, why don't you have this object called a query? Like a generative, a buildable, we didn't call it query, it was called select results or something like that. And someone proposed like a very traditional query builder, which we didn't really have. I mean, well, okay. Well, I'm not totally, I'm not, I'm a little confusing here. We had a query builder, but it wasn't, it wasn't integrated with the ORM because I thought you would write like a core select statement. I guess people that have a UC blog, we wouldn't know what I'm talking about. But the point is the API was kind of all over the place in the early days. It was complicated and still complicated, but it was more complicated because it was not as well planned out. Um, but yeah, so SQL object was active record and I wanted there to be a big indirection between the querying and how you get objects back. And also, um, I read a book, uh, by Martin Fowler called patterns of enterprise architecture and patterns of patterns of enterprise architecture. And he had like this big long list of all these common enterprise patterns that a lot of them I had done like lazy loading. Lazy loading means you have some kind of attribute that when you access it, it goes, oh, let me get that data for you. That's called lazy loading. And then ego loading is like you've done something to make sure that when you get your object, they already have certain data. So I wanted to build those patterns. And the Patterns of Enterprise Architecture book introduced this thing that I had not seen before called the unit of work. pattern which means that if you're going to write changes to a database or other kind of storage system you work with your object model and you accumulate changes all into a big data structure and then you push that whole structure of changes out all at once where you can make intelligent decisions about how those changes are ordered and how they interact with each other And I felt that would be superior to the idea of like object one dot save, object two dot save. Okay, copy the primary key from this object to the foreign key to this other one. Okay, object three dot save. Like all that manual work I felt should be automated. And that's what the unit of work does. And that was the other part of SQL alchemy that was kind of a big deal. And that was the most amazing part. When I first got the unit of work, which was... I hardly knew how to write it. When I first saw it work, I was like, I was like amazed. It was like, it blew my mind because this is old school. We didn't have chat GPT. We didn't have, you know, a lot of machine, I mean, machine learning exists, but like the really impressive things that machine computers do today were not as common back then. And I just saw it emit all these insert update statements. I was like, wow, this is going to be great. I was excited. So, And I think that's what, when people try SQL, they see the unit of work do its thing and they're like, oh, that's really cool. I think that's what people like. They see the unit of work thing and they're like, oh, that's compelling. All I did was put a bunch of objects in a big bag and whoop, they all went in. I think that's kind of one of the selling points of the library overall.
Yeah, I know for me, when I started using SQL Alchemy, I liked it because it interfaced with all of the the different database backends I was dealing with at the time. I think we had like three or four of the big ones for the government work. So we used them all. And I'm like, darn, this is hard. And then I found SQL Alchemy. I'm like, oh, this makes it easy.
Yeah. Yeah, I mean, you know, the other thing with SQL Alchemy is that I really wanted to have this emphasis on we're not going to try to get the lowest common denominator of database vendors' capabilities. Because if you want to make an ORM that, like, okay, you now use this ORM. Don't worry about the database. We're going to do that. That's really what people always thought ORMs were for. And I said that doesn't really work. From my experience at MLB, I was like, look, The ORM is about automating repetitious tasks. Like if you've got 50 different classes, you don't wanna write 50 different insert statements. You want a tool to write that for you, it automates it. But that doesn't mean you have to hide the database. It doesn't mean that if you want your program, if you wanna have a driver for Postgres and you wanna have a driver for MySQL, it doesn't mean that you can't use a Postgres JSON data type because MySQL doesn't have that. It doesn't mean you can't use... You can add features that are specific to different databases because if the people writing code with SQL Alchemy, they also know how the database works. They know they're using Postgres. They know that they want to have it distinct with columns in it, which only Postgres does. They know, like today, they know they want to use this thing called lateral join, which is SQL standard, but I don't think most defenders support it. You know, they know what they're using. They still want to have a tool that automates the tedium of writing the same query over and over again for different classes.
But they're smart enough to use vendor specific features. And that was a big deal because when SQL came out, you know, Django ORM was the other big choice at that time. So somehow SQL object had kind of been displaced by Django ORM and SQL ORM. It's still kind of like that mostly today. Um, you know, Django's ORMs, their philosophy is like, we, we got the database. Don't worry about it. We'll do it. So you, you know, you have a, maybe I haven't looked at it more recently, but back then at least they were trying to make it exactly the same persistence level layer for the Relational databases and people come along, well, I want to use Django ORM or SQL Alchemy with MongoDB, which is a document database, or I want to use it with CouchDB, all these old non-relational databases. I don't know if Django went too far with that, but we were like, no, I don't want to support. We're doing a relational thing here. We're doing a thing that has joins, it has foreign keys, it has schema stuff that And we want you to know what that stuff is. We want you to know what your database looks like. And SQL Alchemy is what I call schema centric. if you're going to write your code with SQL Alchemy, you're going to think about your database first. You're going to write, you're going to develop what your tables look like. You're going to say, I want these tables and these foreign keys in this relationship. And this is what it looks like. This is what a query would look like. If you're going to do the Django way, you're going to go with Django's, you know, their admin UI and, you know, you're going to build a model object first. And then the model uses kind of a pretty fixed subset of patterns that Django will then implement those patterns in the database, which is, Great also, but from my point of view, I was like, my thing is for people that either have an existing database that they can't change or they want to develop a database schema first, because that was how I always wrote apps, was that you developed the database schema first. How are we going to do this? So it's just different philosophies. And that's why also back in those days and still today, I wanted there to be other kinds of ORMs and SQL tools. There was a lot of push back then that Django should be part of Python, batteries included. which I didn't like that idea. I didn't want my thing to be part of Python either. I thought there should be choices. And that's also a SQLAlchemy thing. That's why SQLAlchemy's got this really big pattern of being split. It's got core and ORM, and it's got declarative and imperative. There's all these constant dualisms going on. I didn't want it to be opinionated. I wanted it to be like, if you hate ORMs, you can still use SQLAlchemy. I just want a query builder. You can still use SQL. I was trying to kind of sell it, but also I was trying to sell it to someone who I thought was like me because I hated ORMs that other people wrote. I mean, right. Obviously, you know, NIH, you know, whatever, there you go. I hated like the ORMs for, for a Pearl. I was like, you know, Java, I use Hibernate a little bit, but yeah.
But mostly I like that the field is open. There's different ways to do this. There's a good little ORM called PeeWee that a lot of people love, and they love it because it's simple and great. Go use PeeWee, please, because if you're confused, go over there. Do that because, you know, I wouldn't have used C-Clock. I used C-Clock because I did database stuff for 10 years before I used it. So I knew what I wanted. By all means, don't. This is the problem. People have to use psychologamy for their jobs. People get hired and they're placed to use psychologamy and then they make for very grumpy people because they come to us like, I have to learn this. They don't say it that explicitly, but you could tell they have to learn psychologamy for their job and they don't want to read the docs, which I wouldn't want to read them either. They're trying to do things anyway.
I mean, the thing with docs, people just complain, like, SQLite is the worst docs I've ever seen. You know what it is? It's like, I don't like learning things either. So when I have to learn some package and I don't really want to, I'll be like, what the crap is this? What is that? I hate all this stuff. You know, it's just how it is.
Yeah. But what I don't like is you go and you go look at the docs and they don't have the answers either. Yeah. It's just, well, here's how you create a database. That's it. And you're like, I need more than that. And I think Pee Wee and Pony RM are like the two lightweight ones. And for a long time, their docs were like that. They were very lightweight and didn't give you the information you needed.
Well, that's part of how they skull themselves also is that they want people who are entry level to come there and not be intimidated. Yeah, I know. Because if you use PeeWee, you're going to have 99% of the same problems you would have with C-Quality. It's got all the same issues. It's got the N plus 1 problem. It has fewer ways to get around these problems. You know? I mean, look, personally, I would choose C-Quality over PeeWee because... I know all the things SQL Alchemy does that PeeWee does not do. But if you're intimidated by SQL Alchemy, go to PeeWee because it's not intimidating and you'll get it. You might even read the source code and be like, oh, this is how ORMs work. I didn't know that. And you get some appreciation for that. But yeah, if you're trying to do like the enterprise, sorry, it's just what it is, ORM SQL Alchemy, you've got to document everything. And it's really hard to write docs. I mean, when people come and complain, I've rewritten these docs like 12, 15 times. Like rewritten. For Psycology 2, we threw away the entire tutorial. We're completely writing a tutorial. And, you know, it's hard to document it. It's hard. And you know what? When people come to me with some question and I forgot how to do something, I can't find stuff in the doc. Sometimes I'm like, ah, and then I have to go through and add a lot of cross-linking. And it's just enormous because I'll spend hours and hours adding cross-linking for some area. I see that things aren't cross-linked and you find one little piece of it and it doesn't give you the full story. And it's just, it never ends. It's just this huge tracks of code in the doc strings. And I go there and it's like, this does this. And I'm like, where's the link to the section?
Because AI can't read your code. Like if it was really AI the way I would wish AI was, it'd be like data on Star Trek. You could hand him a laptop from 500 years ago and he'd be like, okay, this is how it works. And I could write, right? That's AI. That's intelligent. That's what I call intelligent. Yeah.
And that's because, especially with SQL, because it's a big library, and we had to refactor things a lot. And whenever we had to refactor, I would spend literally days reformatting code by hand because Python did not have a formatter that didn't suck. There are some formatters and they were all basically trying to look at the code as it was printed in the page. It wasn't actually doing a syntax tree. It was trying to fix white space was trying to fix where you put things. It was trying to kind of heuristically move things around. And black is nothing like that. Black is like, I'm going to read your whole code into a syntax tree and I'm formatting it this way, period.
Just get into our style, which is kind of optimized to reduce merge artifacts. When you're merging, if you have a single line of code with multiple concepts in one line, and one version of the code is this, the other version of the code is that, you get this thing called merge. You get merge conflicts. There's a way to format code that Black is oriented towards to minimize merge conflicts. And it took a while because if you have a list of 20 names, it puts them in a big vertical list. And you're like, oh, that's so big. Oh, whatever. We use IDEs now. I use VS Code. And it's like basically weeks and weeks of time I used to spend working with whitespace constantly. went away. And then all the kind of, you know, people submit a pull request and they have a different whitespace. They have a different formatting paradigm and you don't like theirs and it doesn't go with yours. And everyone's arguing how to do it. You spend so much freaking time. And what I do for my day job, I work for Red Hat. I work with OpenStack, which is a gigantic Python code base. And I think they had tried to start using black and it never took off because it's not, I don't think it's in play yet. It's so, when I go back to working with OpenStack where I, assuming I'm not supposed to be using black right now because I was just using it the other day and there was no, didn't see my black was in play. You've got a format, you run flake eight and it's like, oh, this line is not indented correctly. And it's like, you have to do it with the space bar. And I'm like, wow, this is like ancient. I think everyone that does Python, you should start in black, should be right there. And there are Flakate plugins that make sure your code is black exactly. And then you never have to deal with formatting again. It's just a given. You just deal with code. So black is, that's it. The other Python package, which is very popular now, is pre-commit, which is used for all kinds of languages. It's what happens to be in Python. And that's, again, about code cleanliness. It's so that when you commit your code, you can run Black and Flake 8 and import tidying tools and, you know, everyone, you know, every, every, every, you know, pro level code base uses pre-commit now. I mean, we were doing go at red hat and we use pre-commit for all the go stuff too.
Yeah. So yeah, it just means that you're going to like, before you commit stuff, don't even put it into the repo before it's correctly formatted. And there's, there's ways to get, you know, if you've really got to commit something, you can skip, The flaky, you know. And yeah, but this whole idea that code should be formatted very, very consistently and everyone should use the same formatting really speeds everything up. It speeds all like pull requests and merging. It just is way better that all source code. And certainly when you write in Go, you know, another line, probably Rust also, you know, the IDs, everything is formatted in a pretty rigid style. Like this is how you format this. Like in Go, it doesn't even let me put like if with a bracket, then a new line, then an else. The else has got to be on the same line as the previous bracket, things like that. And it's like, well, that's not how I would do it, but I don't care because that's what the control I. And I don't have to worry about it. So if you don't want to use black, I would say get over whatever your pet formatting is and don't deal with formatting at all. This is not your thing. You're there to write code. Let someone else format it.
I use some weird ones. Yeah. Yeah, I use one called Slots Check. Have you ever heard of Slots Check? Slots check is when you write Python classes and you're using the Dunder slots directive. If you write slots on your class, but your superclass does not have slots, you won't actually be using slots. So slots check actually goes through all of your Python classes that have slots and makes sure that you have slots used all the way up to the root because otherwise having slots is pointless. And we had a lot, and before we used slots check, we had a lot of bugs where, like not big bugs, but like performance issues where we, these are all slots. Why are they creating dicks? Why is the memory so high? Because some class in the hierarchy didn't have slots set up.
And there's no runtime check for that. So slots check, right? And there's a few other little dinky ones like that that we use, like the one that makes sure we have from future import annotations in all of our source files, like a little weird ones. And people would just write these very short linters for Flake 8 because they're in Python.
Yeah. So if you're a musician, and I wish there were more tools like Splitter. I wish, I mean, the thing about AI, I don't like AI, right? But I wish there were more AI music stuff going on. Like when you hear AI music, it sounds terrible. And I wish there was a more flexible ecosystem of musical components. Like I'm a jazz musician, so I want there to be an AI that can just generate like just a bass line. that, you know, and just, just a horn line, you know, and I would actually, you know, work with individual instruments because I am a drummer, so I don't want anyone making any drums because I do the drums, right? So with Splitter, you can take any file, any audio file and, you know, it's not, it's not perfect, but you can split out all the instruments and you can make new kinds and it uses TensorFlow and, you know, it's, It's pretty cool. And also another library that I think is really nicely done is Textual. You've probably heard of Textual. Yeah. It's not a GUI. I've been corrected. It's called a TUI.
Don't say GUI because they're going to correct you. It's not graphical even though it's graphical. It's a Textual. I know. It's a Textual User Interface Library. And it allows you to write kind of an application that has buttons and windows and pop-ups and scrolling things all in an ANSI console. which is super neat because if you just want to write programs to do different things, we're all in consoles as programmers. I don't need to pop open a QT window. I don't need that. I prefer to be able to just SSH to any machine anywhere, and I can just use Textual and have my UI right there. It's very, very portable. And Textual also is... Totally async IO, and luckily I got into async IO enough to know how to do it. So I use Textual, again, for a music application that I have for my own stuff. I have a recording suite that is based on Textual for the front end.
So it's like a front end to recording, and then it runs the FFmpeg to do audio. And it actually can spawn off a splitter as well. I can record myself playing drums with a YouTube video and split out the YouTube video into the instruments and then take away the drums, takes my drums and puts it with the other instruments and then you can put it all back so I can make like a drum cover video. And also when you run Splitter, the audio file has less chance of being flagged That's copyrighted content, which is fine. YouTube can let you in YouTube. You can repost any content you want, but if you want to put a video on for your friends on Facebook, if you're playing like a leds up on song, Facebook will be like, we've taken your video down because it has, you know, copyrighted, but it's, it's, it's fair. You just do anyway.
Yeah, I do drumming. So when I first, like I said, when I first went to college, I was like, I'm not going to be a programmer. I'm going to be a drummer. But I'm just going to do this programming. I'm going to do this engineering thing. So I have something to fall back on, which if you're a musician, having a fallback means you're going to fall back, which I did. So I wasn't a musician. I did play, I did play in bands in the city, but I was at this, I was working for.com, you know, at the same time. So, um, yeah, I play music. Uh, and, uh, I, I actually live outside of people know me to live in New York city. Um, I do spend time in New York city a lot cause I still do music stuff there, but I live outside of town now. uh and uh you know i have a nine-year-old which a nine-year-old son and that's a lot of effort yeah stuff to do right there and uh we have a lot of music here you know we have pianos guitars i play the drums uh you know and i cool i play in a jazz uh thing in the city and that's pretty much it I'm coding a lot though come home or whatever there's always plenty of sequel alchemy things to do and there's red hat things so it's kind of a full time job with sequel alchemy people are always coming in with questions and problems and issues we always have releases going out constantly they never end you always think there won't be anything after this release everything's fixed now And it's like, oh, no, no, no. You know, 12 years later, oh, this will be the last. There's nothing after this really.
I don't know. We're going to get a lot of people saying, I'm trying to run it with no Gil, and there are going to be a lot of problems. There's going to be a lot of bugs in Python. There's going to be a lot of bugs on our side. I don't know. I can tell you, whatever new thing comes out in Python, we've got to do it. When typing PEP44 came out, you know, they're like, does SQL Alchemy support this? I'm like, I don't know. You know, and it took us years because it was like so big that I wasn't going to just, so basically for a long time, Dropbox did SQL Alchemy's typing on their own stubs. And, you know, they weren't really what I would have done. But we didn't put typing in until SQL Alchemy 2.0 because I'm like, okay, this is, I've got to change SQL Alchemy because the way this typing works, I like it. Our library doesn't fit this. We've got to change. So we changed SQL Alchemy big time to work with typing. And that's why I think 2L was great because it integrates with typing. Yeah. But that was what, I mean, I don't think the GIL will be that much work, you know, it's going to be work, but you know, and adding a sync IO was a huge job. Hopefully the GIL will not require as much craziness. But I'm sure things are going to break.
I was trying to keep a list. I don't know where the list went. Here's an issue I found thanks to typing. I was trying to kind of sell it. Because, you know, as you know, some people in Python don't like typing. Especially, I'm going to call him out, Dave Beasley seems to hate Python typing. You know, complains about it so much on Macedon. And I think typing, because look, I came from Java. I came from the world where we had IDEs. When I did C++, I did Microsoft Visual Studio. I came from the strongly typed world and I saw IDEs that can make sure your code is complete and you run it the first time it would work because it was strongly typed. And the same thing with Go. You know, Go, your Go code pretty much works the first time because it compiles. Yeah. So I like that model. And IDEs get so much information. You get drop-downs of all the possibilities. Yeah. So I kept a running list of bugs that were found, but it was just too much work to kind of maintain that list. But, yeah, it certainly allows you to find bugs. Yeah. And it also forces you, if you go the right route with it, to really think, why is this code like this? Maybe it should be like this. It makes more sense of typing. So yeah, I think typing, it took me a very long time to get around to it in SQL Academy because I'm like, oh, this is going to be huge. And I had to make a very gigantic space to do typing. And I'm super glad it's done.
Yeah, it does. Right. But if you're producing a library that people consume at the code production level, you have to be pep 44 times. I mean, it's a must-have. You can't, you know, it's a library. People have your code imported in their module, in their IDE. They need to see what your library can do. And now type 44 is how that's done. So, you know, it's just not really debatable at all.
