Python/c api provides related functions to create Python tuples

Source: Internet
Author: User

If you provide the PyTuple_New () function in Python/c api, use it to create Python tuples. In this case, the PyTuple_New () function is used to return the created tuples. The prototype of functions related to Python/c apis is as follows.

PyObject * PyTuple_New (Py_ssize_t len)

The parameter meanings are as follows.

Len: the length of the created tuples.

After the tuples are created, you can use the PyTuple_SetItem () function to add items to the tuples. The function prototype is as follows.

  • Introduction to the actual content of the Python MD5 file generation code
  • A detailed introduction to Python features
  • Python history and positioning of Python in programming languages
  • The Python design concept is also a new development of computer language applications
  • Actual steps for processing Python/c api numbers

Int PyTuple_SetItem (PyObject * p, Py_ssize_t pos, PyObject * o)

The parameter meanings are as follows.

P: The operation tuples.

Pos: The Position Index of the added item.

O: the added item value.

You can use the PyTuple_GetItem () function in Python/c api to obtain the value of an item in the tuples. The value of the return item of the PyTuple_GetItem () function. The function prototype is as follows.

PyObject * PyTuple_GetItem (PyObject * p, Py_ssize_t pos)

The parameter meanings are as follows.

P: The tuples to be operated.

Pos: The Position Index of the item.

After the tuples are created, you can use the _ PyTuple_Resize () function to re-adjust the size of the tuples. The function prototype is as follows.

Int _ PyTuple_Resize (PyObject ** p, Py_ssize_t newsize)

The parameter meanings are as follows.

P: pointer to the tuples to be operated.

Newsize: the size of the new element group.

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.