I know this surely is basic info or knowledge, but I was wondering (and can't find the answer) what is the meaning or what info is displayed just after one executes the python
command and starts an Interpreter?
For example, what would this mean in this case?:
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
I know this is something one sees every time you start an interpreter on the command line, and perhaps something one overlooks, but now it got me wondering.
Let's look at Python's source code to see exactly what it's doing to generate that message. Since if all else fails, you can just look at the source.
If we search for Type "help", "copyright", "credits" or "license()" for more information.
, one of the results is in Modules/main.c
:
#define COPYRIGHT \
"Type \"help\", \"copyright\", \"credits\" or \"license\" " \
"for more information."
If we see where this is used, we can see that it's in the pymain_header
function - the relevant code is the following:
fprintf(stderr, "Python %s on %s\n", Py_GetVersion(), Py_GetPlatform());
if (config->site_import) {
fprintf(stderr, "%s\n", COPYRIGHT);
}
So, now we need to see what Py_GetVersion()
and Py_GetPlatform()
do.
Py_GetVersion does the following:
static char version[250];
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
return version;
So, now we need to see what Py_GetBuildInfo()
and Py_GetCompiler()
do. PY_VERSION
is the version of Python.
The relevant part of Py_GetBuildInfo()
is:
PyOS_snprintf(buildinfo, sizeof(buildinfo),
"%s%s%s, %.20s, %.9s", gitid, sep, revision,
DATE, TIME);
Inferring from the rest of the code, and the build configuration , gitid
is either the git tag of the current Python version, or if that doesn't exist, the git branch. sep
is just a separator, revision
is the short sha-1 hash of the HEAD
commit of the python source. I assume DATE
and TIME
are the date and time of the build.
The source of Py_GetCompiler
indicates that it outputs [Clang __clang_version__]
, [GCC __VERSION__]
, or [C++]
or [C]
, or something else (such as [MSC]
along with the MSC version) depending on what compiled Python.
Lastly, looking at the code for Py_GetPlatform()
, it's getting the platform of the current Python build. Possible values seem to include win32
, but I'm not sure what the others are, but I assume it refers to the specific Mac and Linux OS versions and such.
So, gathering all this info together, the breakdown is the following:
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Okay, let's look at each part of the message.
Python 3.8.7
- The version of python (obviously) tags/v3.8.7:6503f05
- The github tag of the python repo. If you were to go to this tag on github and looked at the latest commit, you'd find the commit ID which is 6503f05
Dec 21 2020, 17:59:51
- The release date of this commit. Check the tag again and see that the latest commit was on this date.MSC v.1928
- Microsoft C compiler and version. 64 bit (AMD64)
- The 64 bit tells us that this python is 64 bits. See this answer for more explanation on 32 bits and 64 bits.on win32
- The OS information for windows. This is 32-bit windows. I suggest installing the 32 bit python version as the 64 bit python you currently have isn't built for win32.References:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.