How to view the Cpython source code is more reasonable?

background: inadvertently wanting to figure out the implementation of staticmethod , I thought that it could be implemented with a class with _ _ get__ , but it was not clear how the original version of cpython was implemented. I was a little curious that grep took a look at the source code and found that

was mentioned in funcobject.h .
/* The classmethod and staticmethod types lives here, too */
PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;

PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);

but there is only a function header, which is useless, and it is broken here. So he came up to ask for advice:

how to find the specific implementation of the relevant python functions is more reliable? (reliable means "I"m sure you can find it this way, and there won"t be a better way to find it.")
or, when I want to figure out how a function works, are there any general routines to follow?

Mar.23,2021

cpython project is quite big. If you look at it with your head covered, you will be confused and have no way to start. You can take advantage of other people's reading notes, such as my notes: https://www.hongweipeng.com/i.

.
Menu