The Real Python Podcast cover image

Using a Memory Profiler in Python & What It Can Teach You

The Real Python Podcast

00:00

Python

In many cases, when you have like a vector or list kind of a structure. So what happens is that you start pushing things. And once the list of the vector is filled, sorry, it's full. Then what will happen is that when you push another item, it will say, Oh, I don't have enough space and need to grow. This is this pattern also happens in the plus plus with vectors. But if the only thing you'll go does is pushing elements, maybe a better strategy will be to what is called pre allocate. You're going to say, okay, I'm going to need one million elements. So instead of doing that, what you can do is

Transcript
Play full episode

The AI-powered Podcast Player

Save insights by tapping your headphones, chat with episodes, discover the best highlights - and more!
App store bannerPlay store banner
Get the app