Reputation: 141
I have a question that how to clear a list that's formed by PyList_Append()
?
Is there a document about Python/C extension API functions in detail?
Upvotes: 6
Views: 1018
Reputation: 32933
You can use the PySequence_DelSlice function:
# The same as: del L[0:len(L)]
PySequence_DelSlice(L, 0, PySequence_Length(L));
Upvotes: 6
Reputation: 101162
IIRC you have to use PyList_SetSlice
:
PyList_SetSlice(your_list, 0, PyList_Size(your_list), NULL);
Upvotes: 7