How does memory alllocation in python realy work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does memory alllocation in python realy work?

As far as I'm aware in for example C when I created an array of n things an address an a stack in the memory was allocated with that many memory space as the array may would need. so how does appending in python work. is in the last memory space allocated a free space where a potential adress is stored to a location in the memory where the array may continue and the adress is then asigned when I for example use append()?

16th Sep 2020, 8:43 PM
Tim
1 Answer
+ 1
Hi! You can use the 'id' method to read the address of the array elements and check it by your own as follows: hex(id(array_name[index])) I hope it helps you
16th Sep 2020, 9:38 PM
Luciano Curti
Luciano Curti - avatar