https://habrahabr.ru/post/193890/ This page describes how the int type is arranged in python2. However, as I understand it, in python3 it is arranged differently - instead of 24 bytes it takes 28 and contains 4 numbers, not 3. But I did not understand what these numbers mean to him.

  • After a quick look at the article, I can say that you need to look at the definition of the PyObjectInt and PyObject_HEAD structures in the Python3 sources. - insolor
  • What is your question? int in Python is unlimited (therefore, you will not get by with 4 numbers). If you are interested in how CPython implements this, you can look at the type PyLongObject - jfs
  • @jfs And in this file, this type is not defined. - Dima Voronetskiy
  • @insolor Don't you know in which of the files it is defined? - Dima Voronetskiy
  • @DimaVoronetskiy when needed, I clone the repository and start searching by content. Now I can not see. - insolor

1 answer 1

Everything, I figured it out. An int is stored as follows: the first number of the long type is the number of references to an object; the second is the id of the object type, then the actual number stored in several int numbers, and the third number before them is the actual number of these numbers. Thank you very much @insolor and @jfs for your help.