- #71
PeterDonis
Mentor
- 47,397
- 23,687
Vanadium 50 said:I wonder if it allocates memory in non-contiguous blocks
It could, although I'm not sure how that would affect the performance of simple nested for loops over slices of a list that's not being mutated. All of the variable accesses at the C level inside the interpreter should be just pointers.
Vanadium 50 said:Python does garbage collection automatically, right?
Yes. But disabling automatic gc doesn't affect the execution time, so this doesn't seem to be the issue. (Mostly Python deallocates objects based on their reference count going to 0; the automatic gc is for cases that can't be handled that simply, like circular references. I don't think there are any of those in my code.)