zpoint / CPython-Internals

Dive into CPython internals, trying to illustrate every detail of CPython implementation
4.13k stars 435 forks source link

关注你这个很久了,是否考虑过弄个群? #31

Open 425776024 opened 4 years ago

425776024 commented 4 years ago

是否考虑过弄个群?让大家一起交流,分享资料,这方面的教太少好的更少。

Aprilming commented 4 years ago

附议,我觉得很可以

——April

在 2020年7月22日,09:53,425776024 notifications@github.com 写道:



是否考虑过弄个群?让大家一起交流,分享资料,这方面的教太少好的更少。

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/zpoint/CPython-Internals/issues/31, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AD5P437TJLDUPOPMTK62I5TR4ZBBZANCNFSM4PEHCRDQ.

zpoint commented 4 years ago

你好, 目前时间精力不是很充足, 这个 issue 先留着, 等后面建一个再在这里回复(挖个坑)

rodeone2 commented 4 years ago

I will explain how Python works. Cpython was ported over from the ABC Language to C language. It works by running a TTY C language Shell that can both read in clicked file type extensions to read and or to scan live line by line inputs. The file read line type is a passed "int main(argv, char **argc)" that informs Python of the clicked files path.

This file is then read into a buffer and processed. As it is being processed it Lexes and tokenizes everything into tokens with several paths as (tok), (s), (t), (e) and a few others. The Variables are all stored into a C struct with a nested type and value struct inside of it. We call these C Tuple's or you may know them as "Linked Lists".

It also has several other struct C Tuples. One for struct Objects, one for struct Class and one for struct Def(for functions). All of them are tied to the Object struct Tuple so that all of them can be passed by references using the Variable struct. Here is a sample of how it works---

typedef struct _node { // USED AS TYPE BELOW and keeps a constant running list of references... int k; struct _node *next; } node;

struct Var { struct name { const char vname; } struct Type { char type; } struct Value { const reference_value; } }

struct Object { const char objname; //A Live Name Instance struct reference { char CHAR; int INT; double DBL; } }

There is absolutely No _ASM Opt-code or Assembly used in Python. It works by simply matching variable, object, class and function names with char strings either as constant struct stored references or actual string names. All other variable types use either atoi() or strtof() to convert variable assigned values and store them into the values lists C Tuples. Python began by Guido Implementing Sets which were the foundations of the Linked Lists which all use structs as C Tuples for everything else making it dynamic Object Oriented and Reference powerful.

Pythons Interpreter makes heavy use of both Scanners and Calculators which are at the heart of Pythons Interpreter and its language. To understand them more, study the works of early 1980's SmallTalk and or read Tobias Shrieners works with Interpreters. Thank You,, It is nice to see younger generation interested in these studies.

zpoint commented 4 years ago

@rodeone2 Thanks for your sharing, it's an interesting perspective to learn from the history of Python😁🤝

rodeone2 commented 4 years ago

Study Scanners and Calculators from the Book called Object Oriented Programming in Anci C BY Axil Tobias Shriegner. 1993 he explains allot about Sets and Objects in that book. These were in fact used in SmallTalk in 1980-1983 and everything in CPython uses them also to this day.