0

Python list question

“The reason why Python is able to have heterogeneous data types in its lists is because the values are actually pointers to objects in memory” What does pointers to objects in memory mean?

14th Dec 2021, 4:20 AM
Sis Flower
6 Respostas
0
Pointers are variables that hold the memory address of nother variable... But Python does not support pointers, where is this quote from ?
14th Dec 2021, 8:09 AM
Arnaud Brd
0
It is from the computer science slides provided by my teacher. Thank you for your explanation!
14th Dec 2021, 12:11 PM
Sis Flower
0
I'm not a computer science student nor I have studied any of this in detail but what I think it means is that since python is built using c and c++ this may mean that we are actually storing the pointers of those values we want to store in lists. Please do correct me if I'm wrong.
14th Dec 2021, 1:29 PM
Sanjyot21
Sanjyot21 - avatar
0
Seems to me that saying python has "pointers" is wrong vocabulary, and this is kind of important to understand in depth how python works vs other languages that support it. But it is true that lists and variables in python are just references to objects (everything in python is an object). So based on the nature of python, i'd assume the quote means : "Python can have heterogenous data types in its lists because those lists are just referencing locations of different objects (and those are not stored 'together') ". It is almost the same, except for the use of "pointers", which is wrong imho.
14th Dec 2021, 2:30 PM
Arnaud Brd
0
You can find more detailed explanations if you look up how python or c stores information. An example in python of the fact that python does not naturally support pointers : a = 1 b = a a = 2 b ---> will output 1, not 2 This would work (output 2) with pointers in C, which are actually "special" variables (you have to add * after the type iirc)
14th Dec 2021, 2:40 PM
Arnaud Brd
0
Thanks all of you. I have now understood that python does not support pointers. Im gonna take a look at how python store information
15th Dec 2021, 4:51 AM
Sis Flower