[Patches] [ python-Patches-916251 ] Create a freelist for
dictionaries
SourceForge.net
noreply at sourceforge.net
Mon Mar 15 03:47:33 EST 2004
Patches item #916251, was opened at 2004-03-14 20:48
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=916251&group_id=5470
Category: Core (C code)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Neal Norwitz (nnorwitz)
Summary: Create a freelist for dictionaries
Initial Comment:
Neal, here is a simple implementation of freelists for
dictionaries.
I've not yet measured it across multiple applications
and have no basis for knowing what a good maximum
size should be (it's currently set at 100 which costs
about 6K of memory when full).
Right now, it only saves malloc time. It would great to
also save some on the other initialization steps. The
trick would be finding a way for delloc() to a little more
work to save correspondingly more in PyDict_New().
Any review, ideas, independent timings, or creative
thinking are welcome.
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-03-15 03:47
Message:
Logged In: YES
user_id=80475
>> There could be a problem in that the element's are freed.
Sure they are. The dict isn't put on the freelist until
*after* all the
elements are freed by dealloc() and the ma_table is freed.
All that is left is the shell that includes the ma_smalltable.
>> would be better to free older dict refs
No, no refs are kept. The shells are empty and
undifferentiated, so age doesn't matter (just like the
freelist scheme for tuples and frames).
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2004-03-14 23:30
Message:
Logged In: YES
user_id=33168
There could be a problem in that the elements aren't freed.
d = {}
k, v = 1, 2
# create weakref to k and/or v
d[k] = v
del d
The weakref callback wouldn't be called in this case, right?
What are your thoughts on memory reclaimation in general?
I don't know anything about the internals of dict, but if
it's resized very large, should the entries be reduced?
Doing more thinking out loud...I wonder if it would be better to
free older dict refs when the table became full? I think
the answer
may also depend on size, memory locations (pages used), etc.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=916251&group_id=5470
More information about the Patches
mailing list