Why Base.summarysize is not exported to Main?

I find more useful Base.summarysize than sizeof so why summarysize is not exported to Main?

v = collect(1:1000);
s = Set(v);
sizeof(v), sizeof(s)
Base.summarysize(v), Base.summarysize(s)
(Base.summarysize(v), Base.summarysize(s)) ./ 1024
varinfo()
2 Likes

The other question is why should it be exported from Base?

I think because it is more informative than sizeof.

sizeof isn’t just a “less informative” version of summarysize, they’re intended for different things. If you want to know the memory usage of just a single instance, you need to use sizeof. If you want to know the memory footprint of an instance and all the other instances it references, then you need to use Base.summarysize. If the primary instance is deallocated, you are guaranteed that at least the sizeof number of bytes was freed, but fewer than Base.summarysize number of bytes will be freed if some of the referenced instances survived.

Sometimes it gets a bit arbitrary whether a name is exported or not. You don’t want everything documented to get exported because it’ll bloat the namespace. I can see how sizeof may have made the cut because it might be useful in more situations, but it doesn’t really mean much that summarysize didn’t. Tons of useful things aren’t.