From: guido at CNRI.Reston.VA.US (Guido van Rossum)
Date: Mon, 19 Apr 1999 17:31:26 GMT
Subject: Memory and swapping question
In-Reply-To: Your message of "Mon, 19 Apr 1999 18:50:33 +0200."
             <371B5ED8.A9C82170@appliedbiometrics.com> 
References: <371B5ED8.A9C82170@appliedbiometrics.com> 
Message-ID: <199904191731.NAA03862@eric.cnri.reston.va.us>
Content-Length: 1070
X-UID: 702                                                  

> Now, create a list of numbers with the half of big,
> and count the seconds. Afterwards, delete the list
> and again count the seconds.
> 
> >>> x=range(big/2)
> >>> del x
> >>> 
> 
> This will be quite fast, and the deletion will be somewhat
> faster than the creation.
> 
> Now for the big WHY?
> Do the same with big.
> 
> >>> x=range(big)
> >>> del x
> >>> 
> 
> On my system, creation takes about 10 times as for big/2,
> this is ok. But the del takes at least three times as long.
> Besides the fact that integers are never really disposed but
> build up a freelist, why is deletion so much slower now?

Clearly in the second case you're exceeding your physical memory and
paging VM pages in and out of swap space?

My guess: when creating the list you are allocating new VM pages,
which don't require any overhead until they need to be written, but
when deleting it, each page gets read from swap space, modified, and
then written back.  Thus, you're I/O bound, and deleting requires more 
I/O.

--Guido van Rossum (home page: http://www.python.org/~guido/)




