why python cache the string > 256?

s7v7nislands s7v7nislands at gmail.com
Mon Oct 26 10:44:09 CET 2009


hi all:

test.py
#!/usr/bin/python
a = []
for i in xrange(1000000):
    a.append('a'*500)


$python -i test.py     #virt mem 514m in top output
>>del a                   #virt mem 510m

why python cache these string?
In source, I see when object size > SMALL_REQUEST_THRESHOLD, python
would use malloc.
also use free() when string refcount == 0.

do I miss somethong?

thanks!



More information about the Python-list mailing list