In place is not free
transcript
Sort a million integers in place. Surely it needs no extra memory. We measured it on one laptop. The answer was not zero.
Reversing in place used no extra bytes. Reversing into a new list used eight million. A list holds eight bytes for each item here. The integers themselves are shared, not copied. So the copy costs the whole pointer array.
Now sort the same million integers. Sorting in place used about four million bytes. Sorting into a new list used about twelve million. In place still needed a buffer. That buffer is memory the job must have.
In place means the result replaces the input. It does not mean no temporary memory. This sort used a buffer of half the list.
These numbers come from CPython three point eleven. They come from one laptop. Other versions and machines will differ. So measure on the machine you will use.
Count what the code allocates. Full breakdown in the lecture.