Python Memory Management and Tips Transcripts
Chapter: Efficient data structures
Lecture: Different container types

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It's very likely you've got some kind of container for your data.
0:03 That could be a list. We did a bunch with dictionaries just a bit ago.
0:06 Actually, dictionaries containing lists, how meta is that? it could be classes,
0:11 and we also had classes in there.
0:13 So there's all kinds of different containers that we could use.
0:16 But there's some that are interchangeable or somewhat replaceable.
0:19 I could have a list of numbers that, if a list just happens to have numbers,
0:24 Python actually has array types, and
0:26 the more traditional, here's a big chunk of memory in the size of the object
0:31 or the type of object is allocated and set just in line.
0:34 This only works for numbers, but that could be interesting.
0:37 You could have Pandas or NumPy.
0:40 Maybe those things store stuff really efficiently or inefficiently.
0:43 I don't know. We're gonna find out.
0:45 So what we're gonna do in this section as we're gonna look at a simple scenario,
0:49 we're gonna have a bunch of names and bunch of ages
0:51 that correspond to those names.
0:52 So basically details about people, and then we want to try to store them in different
0:58 things: lists, arrays, data frames and so on
1:00 and just ask the question "if we start like this,
1:03 how much memory does it use?" versus "if it's stored like that,
1:06 How much does it use?" Because while certain containers might be more familiar and comfortable
1:11 Or maybe they have capabilities that we need or they're just the first thing
1:16 that you think of, there might be a much better option in terms of memory
1:21 for what you're trying to do,
1:22 and we're gonna sort of compare some of the common ones side by side coming up.