Python C extension (1)

Source: Internet
Author: User

I. Introduction:

1. File Inclusion:

ProgramAll the functions, types, and macros used in the file include:

# Include "python. H"

In this example, the standard header file <limits. h> and <stdlib. h> are implicitly included (if available)

 

Note: Python may have some pre-processing definitions on some systems that affect the standard library functions. You must include python. h before defining the standard header file.

All user-visible functions on python. h usually start with Py _ or _ Py, and all names starting with Py _ are mainly used for internal implementation of Python and should not be used by external programs. There are no restrictions on the naming of struct members.

 

Important: User-Defined code should never start with Py _ or _ Py, which may mislead readers and make it inconvenient to maintain and port later versions, if you want to use these names later. On UNIX, these header files are usually located in prefix/include/pythonversion/and exec_prefix/include/pythonversion /. Pre-fix and exec_prefix are installed Python versions.

 

C ++ users should note that these APIs are completed and implemented in C. The header file declares extern "C" in due time, So C ++ calls do not need to do anything special.

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.