Python Tules, why are you even a thing? Because you're pretty much the same as a list. Like almost exactly the same. Watch this. Here's how I create a list and here's how you create a tule. They're exactly the same. Come on. I mean, I know to create them, I had to use a bracket to create a list. Opening, closing. Beyond that, they're the same. They hold an ordered list of data strings, integers. Why is Python doing this to us? Just to be confusing, to be difficult. Cause I only ever use list. I never used Tules. So in this video, I wanna go on a journey. I want to figure out why is there a tule? Why is it even a thing? Why does it exist? It's gonna be a small journey, I think. Get your coffee ready. Let's do this Now, just to show you I'm not crazy. Let me print the type of these data types. We're on that code and bam, I told you class list class tule. So I googled it, ask chat, G p T and ask my discord. And there's one key difference between a list and a tule immutable. You can't mute Tules, but you can mute lists. But now I'm talking about tules and you can hear me Immutable, not mutable. All right Nick. So what I wanna do there is like do a mute thing. <laugh>, it's stupid, but we should play with it. So it turns out immutable is just a fancy word for you can't change it. Whereas mutable means you can change it. So a list you can change. So let's try it out. Let's change a value in our list. We'll change Bernard to Chuck. We'll say index zero equals chuck. And we'll print that list to see what it looks like. Nailed it. It changed mutable. Let's try to change our two pull, same process. Call the zero index and have that equal chuck and we'll try to print it out and can't do it. It's immutable. Can't touch this. Sorry, I had to do it so we could stop there. Video over. Case closed. But if you're like me, you might be wondering, so what <laugh>, so what if you can't change? I still don't see the reason, the use case because it still seems like we're trying to overcomplicate something that should be very simple. Just make it a list. The list does everything. So I dove deeper. But real quick, before we overcomplicate things with twos and lists, let me tell you something that's not complicated. Sponsor this video. Three cx. Three CX is something you wanna play with because having you always wanted your own phone system. Yes you have. You're about to get one for free. Three CX has a new thing. It's called three CX Startup. Now in the phone system world, things can get pretty complex. Like it was my whole job if that's how much of a pain it was. But here you get the whole shebang, live chat, video chat, a phone system, and it's in the cloud. Like legit. They're doing this now, I don't know how they can do this, but it's free forever for up to 10 users. <laugh>, like seriously, just try this out. It's really fun putting your own phone system right now, take you five minutes. Nothing makes you feel more professional than having a live chat on your website. Let's say you're a person in it and you wanna have a killer resume portfolio website. Imagine if you had live chat on there, <laugh> and a recruiter could come on your website and just start chatting with you. I did this just now. Now it took me about five minutes to set up my cloud phone system. It's kind of stupid easy. And then adding my live chat to WordPress took just a few moments. Check it out. Do you see that at the bottom right chat icon? Because they have a WordPress plugin and it took no time at all. I keep saying that, but that's literally what it took. Say, hey, tell me about Tules. And then bam, looking back at my three CX web client, there's the chat right there. Tules are stupid and I'm helping my client learn about Tules. They don't only have a web client, they've got a client for your phone, Android and iOS. They've got a desktop client. It's stupid how awesome this is. And it's kind of crazy. They're giving it away for free for up to 10 users. Check it out. Link below. Anyways, back to Tules and how stupid they are. I'm just kidding. They're actually pretty cool. That's what I learned. I asked Google again and I asked my discord, and here's what I learned. Two things. Number one, the fact that TU pulls are mutable means they're faster than lists. Like let me show you demonstration time using a tool called time it. We're gonna see how fast Python can create. How many I eight, how many zeros are here? 1 million list and 1 million Tules. Ready, set, go. The results are in and it's obvious, 1.43 seconds for a list and 0.13 seconds for a tule. Dude that made a list cry. But now I'm sure you're wondering why is a tule faster than a list? They're doing the same thing, right? No, and it's back to mutability. Our favorite word and it has to do with storage. Because a list is mutable, you can change it. It's stored in two blocks of memory to allow for new data change data. Whereas a tuple, it's stored in one block of memory, it's not gonna change. And now I know in our example, this little millisecond difference in time doesn't seem like a big thing. But in large, bulky programs, I could be time save, money, save, it's okay. At this point I'm kind of convinced I get it. Two pools are pretty cool. They're fast and I like fast. But now on to 0.2 as to why we use two pools and that's why. Why do we use two pools? What's the use case? When am I going to need data that can be changed? And for that, I asked Google and my Discord and I got fantastic answers. I found a really great answer on Stack Overflow. And it has to do with the types of data you might want to store in a list versus a two and a list. You wanna store what's called homogenous data. That's just kind of fun to say. Go ahead and say it homogenous. For example, a list of names, all strings, the same type of data, list of coffees, list of YouTubers, these are examples of data within a list that we might add to change remove. But in Tules you might use he hetero heterogeneous data. I can't say that. So I might have one tule called YouTuber and it would contain data about a YouTuber name subscriber count. How many does John Hammond have now? Woo. 519,000. Way to go, John Hammond. And the types of videos he makes, packing heterogeneous data. Did I say it right The first time or second time that felt really good. It's all different, but it's all data pertaining to a certain YouTube. Basically it's how we're grouping our different types of data. And when you're working with SQL Libraries in Python, you're actually kind of forced to use tules, the option return tules when you use things like fetch one, fetch all and similar methods and thank you Labret and My Discord. And by the way, if you haven't joined my Discord, check it out. Super helpful. Amazing people in there that'll help you on your Python learning journey. And Grau also points out that you wanna use a tuple for kind of read once data quick stuff and function returns for faster loading speed. We'll talk more about functions later. It's okay, I get it. Tules have their place. They're a thing. I might start using them, probably not, but they're also kind of weird. I'm gonna show you some weird things you can do with them. Actually, this one's kind of cool. You can unpack a tule. So for example, let's have this two bowl here. I'll call it network Chuck. I'll highly equal my name, my age, and my favorite drink coffee. I can unpack this and assign it to multiple variables all at once. By doing this, I'll create three variables, name, age, drink, and half that equal the two bowl network, Chuck. And that legit made three separate variables that unpack it as long as you have them in the correct order. Let me print all of them real quick. Print name, print, age, and print and drink. It's pretty cool, right? Which by the way, you can do the same thing with list. So just now you know it's not unique to Tules, but I hadn't talked about it yet. I wanted to show it to you. Now also, tules are kind of weird. You probably saw this coming cuz they have a weird name. So tuple and I don't even know how to say it, right, is it Tule or a tule? I don't know. Comment below. You probably don't know this. You don't actually need to use parentheses to make a tule. <laugh>. Seriously watch this. Totally. A tule, someone. I'm gonna name this thing equals swan. And then to make it a tule, I don't need parenthesis. All I have to do is just add a com. I want you to need more than one piece of data. <laugh> watch. If I print the type of that data, it's a tule <laugh>, which is so weird. So you actually need parenthesis. All you need is a comma. Like, Hey, I've got multiple pieces of data. Psych <laugh>. So uh, it's weird. And there's more weird things. You can easily turn a tule into a list. Listen to a tule. You can put a list inside a tule. You can put a tule inside a list. You can put a list inside a tule instead, a tule inside a, inside a list, inside a tule, inside a list. And finally, let's make one more tubal stuff you have to do. Like, comment, subscribe, and look. That's a tule. It's immutable. You can't change it. Now you have to do.