Getting global variables using globals() calling from a module

I want a list of "global" variables given by globals() (How to get the list of all initialized objects and function definitions alive in python?).

Now I want to call it from a module, how do I do it?

To state it precisely, suppose in an IDE, I enter

x = globals()

How do I get the same x within a module?


When I am doing data analysis, all my large size objects are in the global level. I have a function to find the highest memory usage object.

def foo:
    objs = globals()                   #line (1)
    object_size = get_object_size(objs)
    return (name_of_largest_size_object)

It works if foo is defined in global level. When I try to wrap it in a module, line (1) does not work: it gives only variables within the module.