Created
October 9, 2019 13:20
-
-
Save worldmind/59e5eb0a22ebe12a8af412525a1d6248 to your computer and use it in GitHub Desktop.
Comparing of tuple, lis, array memory using
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from array import array | |
from pympler.asizeof import asizeof | |
SIZE = 1000 | |
the_array = array('i') | |
the_list = [] | |
for_tuple = [] | |
for i in range(SIZE): | |
for_tuple.append(i) | |
the_array.append(i + 1000) | |
the_list.append(i + 2000) | |
the_tuple = tuple(for_tuple) | |
del for_tuple | |
print(f"Tuple: {asizeof(the_tuple)}") | |
print(f"Array: {asizeof(the_array)}") | |
print(f"List: {asizeof(the_list)}") |
Author
worldmind
commented
Oct 9, 2019
$ python3 --version
Python 3.6.8
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment