[Python-Dev] [Python-checkins] r45925 - in python/trunk: Lib/tempfile.py Lib/test/test_os.py Misc/NEWS Modules/posixmodule.c

"Martin v. Löwis" martin at v.loewis.de
Sat May 13 14:15:34 CEST 2006


M.-A. Lemburg wrote:
> I was leaving those out already - only the codes named 'ERROR_*'
> get included (see attached parser and generator).

Right. One might debate whether DNS_INFO_AXFR_COMPLETE (9751L)
or WSAEACCES (10013L) should be included as well.

I got a smaller source file as I included only forward mappings,
and used a loop to create the backwards mappings.

> Using a lookup object is not really clumsy - you can still access
> all the values by attribute access. The only difference is that
> they don't live in the module namespace, but get accessed via
> an object.

So how much space would that save?

> I'm not worried about the disk space being used. The heap
> memory usage is what's worrying: the import of the module lets
> the non-shared memory size of the process grow by 700kB
> on my AMD64 box.

That number must be misleading somehow. There are 1510 strings,
with a total length of 39972. There are 1510 integers also,
and they all get added into three dictionaries.

On a 32-bit machine, these should consume 76968 bytes for the
strings (*), 18120 bytes for the integers, and 100000 bytes
for the dict entries (**), for a total of 200000 bytes
at run-time.

On a 64-bit machine, the strings should consume 101128 bytes (***),
the integers 24160, and the dict entries 200000 bytes,
for a total of 325000 bytes.

>From that, I would conclude that one should avoid 64-bit machines
if one is worried about memory usage :-)

Regards,
Martin

(*) assuming 20 bytes string header, 1 byte null-termination,
and a rounding-up to the next multiple of 8
(**) assuming 12 bytes per dict entry in three dictionaries
(winerror.__dict__, winerror.errorcode, interning dict),
and assuming an average fill ratio of the dicts of 50%
(***) assuming 40 bytes string header, provided long is
a 64-bit type on that platform


More information about the Python-Dev mailing list