Specifically the source code of lock, which is implemented directly by the _thread extension module.
Answered by Tim Peters, the Cpython implementation:
github.com/python/cpython/blob/master/Modules/_threadmodule.c