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. That could be a list. We did a bunch with dictionaries just a bit ago.
0:07 Actually, dictionaries containing lists, how meta is that? it could be classes, and we also had classes in there.
0:14 So there's all kinds of different containers that we could use. But there's some that are interchangeable or somewhat replaceable.
0:20 I could have a list of numbers that, if a list just happens to have numbers, Python actually has array types, and
0:27 the more traditional, here's a big chunk of memory in the size of the object or the type of object is allocated and set just in line.
0:35 This only works for numbers, but that could be interesting. You could have Pandas or NumPy.
0:41 Maybe those things store stuff really efficiently or inefficiently. I don't know. We're gonna find out.
0:46 So what we're gonna do in this section as we're gonna look at a simple scenario, we're gonna have a bunch of names and bunch of ages
0:52 that correspond to those names. So basically details about people, and then we want to try to store them in different
0:59 things: lists, arrays, data frames and so on and just ask the question "if we start like this,
1:04 how much memory does it use?" versus "if it's stored like that,
1:07 How much does it use?" Because while certain containers might be more familiar and comfortable
1:12 Or maybe they have capabilities that we need or they're just the first thing that you think of, there might be a much better option in terms of memory
1:22 for what you're trying to do, and we're gonna sort of compare some of the common ones side by side coming up.


Talk Python's Mastodon Michael Kennedy's Mastodon