memory overhead using from-import?

William Trenker wtrenker at hotmail.com
Sun Dec 21 10:10:34 EST 2003


Erik Max Francis wrote:

> Consider that the objects created in a module can be highly
> interdependent on each other

Yes, you are right.  Usually it makes no sense to import one "piece" of
a module because of the inter-connectedness.

> The bigger question here is why you think you really should be
> avoiding the full importation of the module.

In this case, the "piece" is totally independent of anything else in the
module.  And this piece (cgi.escape) is a very small function.  I was
hoping to "lift" just this one, small independent function since it's
functionality is quite common.

> The overhead involved in an interpreted language like
> Python for importing the cgi module and only using one function inside
> it vs. avoiding the importation at all is extremely minimal.

The cgi module adds 1.46 megabytes to the virtual memory size of the
process into which it is imported.  That seems excessive considering I
only want access to a small, independent function.  

Yes, on today's gigabyte computers a megabyte isn't worth worring about.
 But on old systems and on embedded processors, the memory size can be
important.

Thanks for replying,
Bill





More information about the Python-list mailing list