Is there pointers concept in python?
so im learning python after doing C. so i learned abt memory management, pointers etc but in python its very simplified and we dont learn much underneath the hood can someone explain me?
1 Answer

Ah, coming from C to Python can feel like going from driving a manual transmission car to an automatic! Let me break this down in a way that'll make sense.
Short answer: Python does have pointers, but they're completely hidden from you. Everything in Python behaves like a pointer behind the scenes, but you never directly manipulate memory addresses like in C.
Here's the key difference:
- In C, you explicitly create pointers (
int *x), dereference them (*x = 5), and deal with memory addresses (&y). - In Python, every variable is automatically a reference to an object (similar to how pointers work), but the language handles all the memory stuff for you.
Simple example:
# In Python
a = [1, 2, 3]
b = a # This acts like passing a pointer - both point to the same list
b[0] = 99
print(a) # Output: [99, 2, 3] (changed the original through 'b')
This happens because and are both references to the same list object - just like pointers in C pointing to the same memory location.
Have something to add?
Join thousands of IIT Madras BS students on BSPrep. Login to ask your own doubts, reply to peers, and access premium tools.
Login to Post