Source code Analysis for Python int

Source: Internet
Author: User

Find the definition of an integer in Intobject.h

The data for the Python integer object is actually saved in Ob_ival, which is a long type in C. Pyobject_head should be a description of the integer object. Know from the source description that Pyobject_head defines initialization information for an integer object

where typedef struct _TYPEOBJECT{}PYTYPEOBJECT,PYTYPEOBJECT can be thought of as the most common, most primitive class of objects, used by other integers, strings, and other objects to inherit.

Pyapi_data (Pytypeobject) Pyint_type;, you can guess, Pyapi_data is a wrapper declaration that inherits pytypeobject from an integer object type. The assignment of Pyint_type can be found in intobject.c

You can see that Pyint_type's parent class initialization is done through Pytype_type.

Int_as_number is a collection of operations for integer objects, and this is no longer a closer look. It's worth noting that Int_doc, this is the document information for an integer object

Source code Analysis for Python int

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.