Python list.clear complexity
问题 What is the complexity of the Python 3 method list.clear() ? It is not given here: https://wiki.python.org/moin/TimeComplexity In the documentation it is said to be equivalent with del a[:] , but I do not know the complexity of this function itself. Is it O(n) or O(1) ? I took a look in listobject.c . Found this. int PyList_ClearFreeList(void) { PyListObject *op; int ret = numfree; while (numfree) { op = free_list[--numfree]; assert(PyList_CheckExact(op)); PyObject_GC_Del(op); } return ret; }