Brett Cannon wrote: > Well, I am a little leery of another free list. I personally don't > love the fact that there are various caches and free lists laying > about in the code without a central place to turn them off or clear > them (or at least list them in a comment somewhere). And the problem > with the free lists that the caches don't have is that they assume > everyone gets a performance perk from them when there is a chance no > one will ever touch a thing in the free lists.
I understand your objection. Most free lists and caches are limited but some are not. I'm worried about the float and int blocks. Python's memory management never frees an int or float block. Code like >>> x = [float(i) for i in list(range(1000000))] >>> del x creates a million float and int objects but *never* frees the memory until Python exists. It's a pathologic case but it shows a problem. I've started to implement an API to compact the free lists, PyNAME_CompactFreelist() and sys._compact_freelists(). My new sys._compact_freelists() deallocates the float and int blocks which do not contain a referenced object. Most free lists are limited except the int (2.x only ) and float blocks. The overview may not be complete and 2.x may have more free lists. bytesobject ----------- no free list, only a single nullbyte classobject ----------- unlimited *free_list of PyMethodObject dictobject ---------- *free_dicts[] limited to 80 entries frameobject ----------- a zombie frame on each code object limited *free_list (linked list) with 200 entries max floatobject ----------- unlimited blocks of allocated floats with 1000 entries each The blocks are a single linked list and the free floats are linked by ob_type (ob_type points to the next free float). intobject (2.x) --------------- same as floatobject listobject ---------- *free_lists[] limited to 80 entries longobject ---------- cache for small number between -5 and +256 my patch for a limited free list methodobject ------------ unlimited *free_list of PyCFunctionObject setobject --------- *free_sets[] limited to 80 entries stringobject ------------ cache for nullstring and strings with one entry interned strings (2.x only) tupleobject ----------- 20 free lists for tuples with up to 20 entries. Each free list is limited to 2000 entries. unicodeobject ------------- *unicode_freelist limited to 1024 entries Christian _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
