@@ -28,6 +28,13 @@ list_size(PyObject *Py_UNUSED(module), PyObject *obj)
28
28
RETURN_SIZE (PyList_Size (obj ));
29
29
}
30
30
31
+ static PyObject *
32
+ list_get_size (PyObject * Py_UNUSED (module ), PyObject * obj )
33
+ {
34
+ NULLABLE (obj );
35
+ RETURN_SIZE (PyList_GET_SIZE (obj ));
36
+ }
37
+
31
38
static PyObject *
32
39
list_getitem (PyObject * Py_UNUSED (module ), PyObject * args )
33
40
{
@@ -67,6 +74,22 @@ list_setitem(PyObject *Py_UNUSED(module), PyObject *args)
67
74
68
75
}
69
76
77
+ static PyObject *
78
+ list_set_item (PyObject * Py_UNUSED (module ), PyObject * args )
79
+ {
80
+ PyObject * obj , * value ;
81
+ Py_ssize_t i ;
82
+ if ( !PyArg_ParseTuple (args , "OnO" , & obj , & i , & value )){
83
+ return NULL ;
84
+ }
85
+ NULLABLE (obj );
86
+ NULLABLE (value );
87
+ value = Py_XNewRef (value );
88
+ PyList_SET_ITEM (obj , i , value );
89
+ Py_RETURN_NONE ;
90
+
91
+ }
92
+
70
93
static PyObject *
71
94
list_insert (PyObject * Py_UNUSED (module ), PyObject * args )
72
95
{
@@ -108,6 +131,42 @@ list_getslice(PyObject *Py_UNUSED(module), PyObject *args)
108
131
109
132
}
110
133
134
+ static PyObject *
135
+ list_setslice (PyObject * Py_UNUSED (module ), PyObject * args )
136
+ {
137
+ PyObject * obj , * value ;
138
+ Py_ssize_t ilow , ihigh ;
139
+ if ( !PyArg_ParseTuple (args , "OnnO" , & obj , & ilow , & ihigh )){
140
+ return NULL ;
141
+ }
142
+ NULLABLE (obj );
143
+ NULLABLE (value );
144
+ value = Py_XNewRef (value );
145
+ return PyList_SetSlice (obj , ilow , ihigh , value );
146
+
147
+ }
148
+
149
+ static PyObject *
150
+ list_sort (PyObject * Py_UNUSED (module ), PyObject * obj )
151
+ {
152
+ NULLABLE (obj );
153
+ RETURN_INT (PyList_Sort (obj ));
154
+ }
155
+
156
+ static PyObject *
157
+ list_reverse (PyObject * Py_UNUSED (module ), PyObject * obj )
158
+ {
159
+ NULLABLE (obj );
160
+ RETURN_INT (PyList_Reverse (obj ));
161
+ }
162
+
163
+ static PyObject *
164
+ list_astuple (PyObject * Py_UNUSED (module ), PyObject * obj )
165
+ {
166
+ NULLABLE (obj );
167
+ return PyList_AsTuple (obj );
168
+ }
169
+
111
170
112
171
113
172
@@ -116,16 +175,18 @@ static PyMethodDef test_methods[] = {
116
175
{"list_check_exact" , list_check_exact , METH_O },
117
176
{"list_new" , list_new , METH_O },
118
177
{"list_size" , list_size , METH_O },
178
+ {"list_get_size" , list_get_size , METH_O },
119
179
{"list_getitem" , list_getitem , METH_VARARGS },
120
180
{"list_get_item" , list_get_item , METH_VARARGS },
121
181
{"list_setitem" , list_setitem , METH_VARARGS },
182
+ {"list_set_item" , list_set_item , METH_VARARGS },
122
183
{"list_insert" , list_insert , METH_VARARGS },
123
184
{"list_append" , list_append , METH_VARARGS },
124
185
{"list_getslice" , list_getslice , METH_VARARGS },
125
- // {"list_set_slice" },
126
- // {"list_sort"},
127
- // {"list_reverse"},
128
- // {"list_as_tuple" },
186
+ { "list_setslice" , list_setslice , METH_VARARGS },
187
+ {"list_sort" , list_sort , METH_O },
188
+ {"list_reverse" , list_reverse , METH_O },
189
+ { "list_astuple" , list_astuple , METH_O },
129
190
{NULL },
130
191
131
192
0 commit comments