开发者

allocating memory for list - Python

I have a small problem. How do I allocate some memory for a list. Let's say it'll have 开发者_JS百科4 elements, but this code gives error that it can't assign to operator.

char *buf1 = int* PyMem_New(int, 4)

Maybe it's late, but I need it for my college assignment.

THANK YOU very much!


PyList_New() allows you to specify an initial size in the single mandatory argument. Don't forget to actually set the items with PyList_SetItem() before using the list in Python code though.


I believe buf1 needs to be a pointer.

char *buf1 = PyMem_New(int, 4);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜