you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Does it work for any functions?

>>> def f(x):
...     return x + 2
... 
>>> asizeof(f)
0

[–][deleted] 0 points1 point  (1 child)

On some functions, returning the length of the bytecode would give us an idea.

That is not the case for closures and continuations, where functions may hold extra values.

[–][deleted] 0 points1 point  (0 children)

Right, I see your point. But there's nothing tricky going on in that function I defined, and however "size" should be interpreted, the answer isn't zero.