While inspect.getsource()
can retrieve the source code for objects written in Python, list
is written in C, so there's no Python source for getsource()
to retrieve.
If you're comfortable reading C, you can find the complete source code for Python at its official GitHub repo. For example, the source of list
for various releases can be found at:
- https://github.com/python/cpython/blob/master/Objects/listobject.c (latest development version)
- https://github.com/python/cpython/blob/3.6/Objects/listobject.c
- https://github.com/python/cpython/blob/2.7/Objects/listobject.c
... and so on.