How to reduce the memory size of python
Terry Reedy
tjreedy at udel.edu
Thu Jan 7 13:31:48 EST 2010
On 1/7/2010 3:34 AM, Mishra Gopal-QBX634 wrote:
>
> Like import logging takes 1MB of memory.
> We only use on function getLogger by 'from logging import getLogger'
>
> But it still take the same 1 MB memory.
>
> Instead of loading whole logging module only load the getLogger
> function.
from x import y
causes creation of module x and binding of the module to sys.modules'x].
It then binds name 'y' in the current namespace to the corresponding
object in x. Functions in general need a reference to the module
namespace to resolve module-level variables.
To save anything, you must cut the function out of the module and verify
that it works in isolation. But I presume 'getLogger' refers to other
stuff in the logging module and would not work in isolation.
Terry Jan Reedy
More information about the Python-list
mailing list