[Python-Dev] py2.7: dictobject not properly resizing (original) (raw)
Micha Gorelick mynameisfiber at gmail.com
Sun Mar 31 18:51:26 CEST 2013
- Previous message: [Python-Dev] py2.7: dictobject not properly resizing
- Next message: [Python-Dev] Idle, site.py, and the release candidates
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
So I did a bit of benchmarking and attached is the code I used. With downsizing happening when ma_used * 2 <= ma_filled, or the following for the condition in question:
if (mp->ma_used <= n_used || (mp->ma_fill*3 < (mp->ma_mask+1)*2 &&
mp->ma_used*2 > mp->ma_fill))
I see marginally faster performance with downsizing. I chose a factor of 2x because it will ensure downsizings before the ma_fill load factor comes into play and will also not cause a resize on the next insert. Using the vanilla python2.7.3 code, there are never any resize events where the new size is smaller than the old size.
Cheers, Micha
http://micha.gd/ http://github.com/mynameisfiber/ -------------- next part -------------- A non-text attachment was scrubbed... Name: test.py Type: application/octet-stream Size: 1060 bytes Desc: not available URL: <http://mail.python.org/pipermail/python-dev/attachments/20130331/697c6e1d/attachment.obj>
- Previous message: [Python-Dev] py2.7: dictobject not properly resizing
- Next message: [Python-Dev] Idle, site.py, and the release candidates
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]