How can I find out more about the internal components of Pythons?

I've been programming Python for a little over half a year, and I'm more interested in the internal Python environment, rather than using Python to develop applications. I am currently working on porting multiple libraries from Python2 to Python3. However, I have a pretty abstract idea of ​​how to make port contents from Python2 to Python3, since most of the changes are related to design issues in Python2.x

I would like to learn more about the internal components of Python; Should I use a top-down or bottom-up approach? Are there any links you could recommend?

+41
python internals
Jul 21 '10 at 10:59
source share
6 answers

It looks like you want to learn more about the rationale for language design, not the inner one. β€œInteriors” for me means such things as how objects are laid out in memory, how reference counting works, etc.

If you are looking for a deeper understanding of design decisions, try reading PEPs : these are suggestions for changes to the language, and often include a detailed discussion of the reasons for the changes, rejected alternatives, etc. Even rejected PEPs are useful because they show the thinking that shaped the language.

For example:

etc.

If you really want to learn about the internal components of Python, start by reading the Python C API, which is used to create Python itself: my talk A Whirlwind A tour through Python C Extensions is one place to start. You can then dive into the Python source code for everything you need to know.

+29
Jul 21 '10 at 11:33
source share

Someone who stumbles upon this question from related links or searches has documentation written by Yaniv Aknin in Internals Python . It starts from scratch and is well read.

+15
May 09 '11 at 4:17
source share

I find the Yaniv Aknin Pythons Innards series fantastic, too

I discovered this thanks to Planet Python

.

You might also be interested in TryPyPy's answer in this SO thread.

+4
May 9 '11 at 6:48
source share

First I read What New for Python 3. It gives a good overview at a high level and touches on the detailed changes.

You can also do a port search on python 3 or similar. There are many good resources and tools.

One tool that is new and hard to find is six , Benjamin Peterson. This allows you to write code compatible with the Python 2 * 3 space.

The part that made it harder for me to support Python 2 and Python 3 compatible code was deployment. I could write code that would work just fine, but when I went to do the package and deploy, it was not clear when the conversion would happen. In the end, I found the distutils build_py_2_to_3 that would do the trick. Using this command in my setup.py, I can free the source distribution, which will be deployed either in Python 2 or Python 3. An example can be found in jaraco.util.

You also asked about the insides. If you really want to get inside information, you can look at the source of Python 2.x and Python 3.x , although, to be honest, I would stick to reading tutorials and maybe some of the .py files in Python folders.

+1
Jul 21 '10 at 11:22
source share

Should I go from top to bottom or bottom to top?

AND! Really.

+1
Jul 21 2018-10-21T00:
source share
0
Jul 21 '10 at 11:22
source share