Since Python is open source you can read the source code from the official python website
To find out what file a particular module or function is implemented in you can usually print the __file__ attribute. Alternatively, you may use the inspect module.