Skip to content

pointers

jasper-zanjani edited this page Aug 6, 2020 · 1 revision

Python, which emphasizes abstraction and usability, does not support pointers natively. realpython.com But there are some features of Python which provide the benefits of pointers.

  • id(object) Return {object}'s memory address
  • object is other return True if {object} and {other} share the same memory address

Mutable primitives list, set, dict can be used to simulate pointers, since their memory address will not change. Custom objects can also be used to recreate the behavior of pointers. Lastly, the ctypes module allows you to use shared libraries compiled from C programs, calling C functions from within Python. dbader.org