[Python-Dev] More compact dictionaries with faster iteration (original) (raw)
Raymond Hettinger raymond.hettinger at gmail.com
Tue Dec 11 00:17:57 CET 2012
- Previous message: [Python-Dev] More compact dictionaries with faster iteration
- Next message: [Python-Dev] More compact dictionaries with faster iteration
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Dec 10, 2012, at 2:48 AM, Christian Heimes <christian at python.org> wrote:
On the other hand every lookup and collision checks needs an additional multiplication, addition and pointer dereferencing:
entry = entriesbaseaddr + sizeof(PyDictKeyEntry) * idx
Currently, the dict implementation allows alternative lookup functions based on whether the keys are all strings. The choice of lookup function is stored in a function pointer. That lets each lookup use the currently active lookup function without having to make any computations or branches.
Likewise, the lookup functions could be swapped between char, short, long, and ulong index sizes during the resize step. IOW, the selection only needs to be made once per resize, not one per lookup.
Raymond -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20121210/0f908861/attachment-0001.html>
- Previous message: [Python-Dev] More compact dictionaries with faster iteration
- Next message: [Python-Dev] More compact dictionaries with faster iteration
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]