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

M.-A. Lemburg mal at egenix.com
Tue May 16 13:40:01 CEST 2006


Martin v. Löwis wrote:
> M.-A. Lemburg wrote:
>> Well, the strings and integers count twice: once in the module
>> namespace and once in the errorcode dictionary.
> 
> That shouldn't be the case: the strings are interned (as they
> are identifier-like), so you have the very same string object
> in both dictionaries.
> 
> The numbers shouldn't be duplicated because they occur
> in the co_consts array of the global code object, and because
> the compiler should share them there.

Hmm, you're right.

>> Given that the code strings and integers are created
>> twice in my version of the module, the numbers sound about
>> right.
> 
> If they are indeed created twice, something is wrong.
>
>> I agree that creating only one dictionary statically
>> and the other mapping dynamically will already be a
>> saving of 50% simply by sharing the string and integer
>> objects.
> 
> No, they should be shared already, so that shouldn't save
> anything.

I changed the generator to now use only one dictionary
and create the module symbols at import time. Here's
the new data:

USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND

Before:

lemburg  29980  0.0  0.4 19936 4620 pts/3    S+   13:27   0:00 python

After the import:

lemburg  29980  0.0  0.5 20756 5260 pts/3    S+   13:27   0:00 python

The RSS changed by 640kB - only 60kB less than with the
static approach.

I also tried this on a 32-bit machine: the RSS changes by 392kB.

Next to come: the C extension version...

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 16 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Python-Dev mailing list