Dynamically create and return a Python list in a Python C extension

I am writing a Python extension in C , and I'm trying to figure out how to dynamically build and return a Python list using my extension. I know how to create a list of a given size using Py_BuildValue . Is there a way to create a list with Py_BuildValue and then add items to this list? Is there any other and better alternative?

+3
source share
1 answer

How about using it PyList_Append, just like (link topology management and more) would you use .appendin Python?

list API, .

+4

Source: https://habr.com/ru/post/1725764/


All Articles