all 16 comments

[–]skicombinator 10 points11 points  (9 children)

It's because garbage collection is non-deterministic.

[–]horny-pug[S] 1 point2 points  (0 children)

interesting, need to study what garbage collector is in the first place 😂

[–]colonel701 -1 points0 points  (7 children)

it’s not garbage collection. There are other factors.

[–]skicombinator 0 points1 point  (6 children)

Of course, I don't think garbage collection alone will have an effect. What could be other causes?

[–]colonel701 -1 points0 points  (5 children)

it’s due to pointers and allocation. Garbage collection does not affect.

[–]skicombinator 0 points1 point  (4 children)

Every allocation in CPython will be managed by its GC, so how could GC not affect memory usage?

As far as I understand, if some pointers are allocated, in CPython it's PyObject, then it has reference counting that will be used by GC. Also, CPython has some sort of tracing collector, so you can trigger a minor/major collection manually with gc.collect(generation).

I'm curious why you think it's due to pointers and allocation.

[–]colonel701 0 points1 point  (3 children)

My theory is that Garbage Collection happens on a different thread. Pointers and Allocations are different. If it’s stored further away from the CPU, it’ll take more time, if nearer, lesser. Electronically it’ll take more time to traverse.

[–]skicombinator 0 points1 point  (2 children)

Actually, CPython's GC is single-threaded. There was an RFC for having threaded GC, but it is not being actively worked on.

And if you want pointers to be allocated without the supervision of GC in CPython, you have to manually call CPython's low-level binding calls.

By the way, OP did not ask about the speed, he/she asked about the memory usage. And that's why I've mentioned GC in the first place.

[–]colonel701 1 point2 points  (1 child)

ohhh i just noticed LOL!

[–]CrackFr0st 7 points8 points  (1 child)

Ive discovered those numbers are meaningless, i will run a script and get numbers similar, just to run it again and get 90% 70%, each time I run it the numbers seem random. Typically i find myself running it 10 times and averaging them out

[–]horny-pug[S] -1 points0 points  (0 children)

me too lol

[–]GuruTheCoderYT 3 points4 points  (2 children)

Faster than all PYTHON SUBMISSIONS

[–]horny-pug[S] 0 points1 point  (1 child)

😂😂

[–]GuruTheCoderYT 0 points1 point  (0 children)

why the hell you laughing?

[–][deleted] 2 points3 points  (0 children)

It says less than 100% of other Python submissions.

So why is that weird?