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 a and b are both references to the same list object - just like pointers in C pointing to the same memory location.
What you don't have in Python:
- No
&address-of operator - No
*dereference operator - No pointer arithmetic
- No direct memory management
The Python interpreter handles all memory allocation/deallocation for you (through garbage collection). This makes coding easier but means you lose some low-level control.
When you need similar functionality:
- For pointer-like behavior: Just use normal variable assignment (it already works that way)
- For memory control: Use modules like
ctypesif you really need low-level access (rarely necessary)
The mental model shift is: In Python, think in terms of "objects" and "references to objects" rather than memory addresses. Everything is passed by "object reference" automatically.
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