Problem slicing a list with the C API
Jen Kris
jenkris at tutanota.com
Sat Mar 12 18:30:55 EST 2022
Chris, you were right to focus on the list pDictData itself. As I said, that is a list of 2-tuples, but I added each of the 2-tuples with PyList_Append, but you can only append a tuple to a list with the extend method. However, there is no append method in the C API as far as I can tell -- hence pDictData is empty. I tried with PyList_SetItem but that doesn't work. Do you know of way to "extend" a list in the C API.
Thanks very much.
Jen
Mar 12, 2022, 13:57 by rosuav at gmail.com:
> On Sun, 13 Mar 2022 at 08:54, Jen Kris <jenkris at tutanota.com> wrote:
>
>>
>>
>> pDictData, despite the name, is a list of 2-tuples where each 2-tuple is a dictionary object and a string.
>>
>
> Ah, gotcha. In that case, yeah, slicing it will involve referencing
> the tuples all the way down the line (adding to their refcounts, so if
> there's a borked one, kaboom).
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list