In this lesson, you are going to learn how much space Python objects use in memory. You will also learn how other programming languages represent some of the most common data types such as integers. Python is actually quite different from most other languages in this regard. Even though you will mostly program in Python, this knowledge will prove helpful when you learn about databases.

In addition, you will learn a new way to represent integers that uses a fixed number of bits and allows them to represent both positive and negative integers. You will also learn about size units in a computer and how to compute the size of a python object in memory as well as a file on disk. You will also leverage what we have learned about encodings to be able to estimate the size that data will occupy.

As you work through this lesson and learn about memory and disk usage, you’ll get to apply what you’ve learned from within your browser; there's no need to use your own machine to do the exercises. The Python environment inside of this course includes answer-checking to ensure you've fully mastered each concept before learning the next.


  • About fixed bit integers.
  • About internal representation of integers.
  • About the two's complement representation.
  • How to know how much memory a variable takes.
  • How to reduce the disk usage of data with encodings.

Lesson Outline

1. Fixed Bit Integers
2. Two's Complement Representation
3. Range of Two's Complement
4. Why Two's Complement
5. Identifying the Number of Bits
6. Memorry Consumption of Textual Data
7. Python Internal String Representation
8. Disk Consumption of Textual Data
9. Estimating the Disk Requirements
10. Next Steps
11. Takeaways