From the course: Python: Programming Efficiently
Unlock the full course today
Join today to access over 23,300 courses taught by industry experts.
Memory profiling - Python Tutorial
From the course: Python: Programming Efficiently
Memory profiling
- Just as we can profile CPU usage, we can do the same for the other crucial computing resource memory. Unfortunately in Python memory profiling is both harder and less precise because the interpreter manages memory automatically and that's not always allocated or released in the way that we would expect. Nevertheless, we can get a good sense of what's happening and we can compliment profiling with a theoretical understand of how different Python objects may use very different amounts of memory to store the same data. Let's begin with a simple case of an array of a million floating point numbers. The simplest way to store them in Python is perhaps a list which we can make with a usual list comprehension. Alternatively, we can use a NumPy array. These two look similar but they're actually very different internally. Python lists are implemented using dynamic arrays, a set of pointers, stored consecutively in memory…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Computer architecture and optimization techniques1m 38s
-
(Locked)
Time profiling8m 19s
-
(Locked)
Memory profiling6m 42s
-
(Locked)
Algorithm complexity3m 24s
-
(Locked)
Introduction to parallel programming3m 49s
-
(Locked)
Challenge: Inverted index2m 18s
-
(Locked)
Solution: Inverted index1m 39s
-
(Locked)
-