I may not see it right away, but I downloaded the python source. (It may be better to download the source of 3.4, but for now, I'm downloading the source of 2.7 (Python-2.7.7) I'm using) In the future, you may even see the contents of the source by checking (as an aid to) the specifications.
For the time being, look for the entrance of python.exe.
First, search with main (). Some mains were found, including Demo. You can get a rough idea of the file name, but also look at the Makefile to confirm the search results.
As a result of the search, the following line was found in PC / os2emx / Makefile.
PYTHON.EXE= python.exe
Where I'm building this guy
$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
$(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.EXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)python.def
$(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
So, the definition of SRC.EXE is
SRC.EXE= $(TOP)Modules/python.c
The contents of this source (Modules / python.c) are as follows.
/* Minimal main program -- everything is loaded from the library */
#include "Python.h"
#ifdef __FreeBSD__
#include <floatingpoint.h>
#endif
int
main(int argc, char **argv)
{
/* 754 requires that FP exceptions run in "no stop" mode by default,
* and until C vendors implement C99's ways to control FP exceptions,
* Python requires non-stop mode. Alas, some platforms enable FP
* exceptions by default. Here we disable them.
*/
#ifdef __FreeBSD__
fp_except_t m;
m = fpgetmask();
fpsetmask(m & ~FP_X_OFL);
#endif
return Py_Main(argc, argv);
}
API While examining the above, I thought that the python API had an entry defined in python.def. The contents of python.def look like this. (Excerpt)
LIBRARY PYTHON24 INITINSTANCE TERMINSTANCE
DESCRIPTION 'Python 2.4 Core DLL'
PROTMODE
DATA MULTIPLE NONSHARED
EXPORTS
; Data
PyCFunction_Type
・ ・ ・
; Code
PyArg_Parse
・ ・ ・
Py_Initialize
Py_IsInitialized
Py_Main
Py_MakePendingCalls
Py_Malloc
Py_NewInterpreter
Py_Realloc
・ ・ ・
Of course, there is also an API reference site.
-Python / C API Reference Manual
If you're looking at the source, you might want to start with an API entry.
In the Demo folder in the downloaded source, there was something like sample code using the API. I don't know if I will use the API, but it may be helpful if I use it.
When I tried to read the python source, I searched the site for the analyzed information, but I haven't found it so far. It would be helpful if I could understand the outline. If I investigate a little more and find interesting material, I may post an article.
Recommended Posts