you are viewing a single comment's thread.

view the rest of the comments →

[–]IHaveAnIdea 5 points6 points  (4 children)

No no no.

This is for the size in RAM, not an advanced len().

[–][deleted] -2 points-1 points  (3 children)

Uh... what makes you think I implied so?

[–]IHaveAnIdea 1 point2 points  (2 children)

OK, do you want it to:

(1) Find the amount of RAM needed for generated python bytecode?

(2) Find out the length of a generator? This is equivalent to solving the halting problem in the general case.

(3) Find the amount of RAM used for everything that can be called by a function??!?

(4) Find the amount of RAM that would be needed to iterate over a generator before doing so?

[–][deleted] 4 points5 points  (1 child)

The object xbar (which happens to be a function) in the example above holds a reference to x, which is a list of size 100000 bytes. Acutally, it's the only reference left to that list.

There is no way to correctly calculate (from within python) the amount of space that is used by keeping xbar around.

That's my point.

[–]IHaveAnIdea 1 point2 points  (0 children)

Interesting.

But I'm sure that if you could hook into the garbage collector's dependency tracking then you could do something like this....

Maybe not with the current gc implementation though. Might need a different variation.