New submission from Dan Schult <dsch...@colgate.edu>:

In the depths of dictobject.c one can see that dict_setdefault uses two 
identical calls to PyObject_Hash and ma_lookup.  The first to see if the 
item is in the dict, the second (only if key is not present) to add the 
item to the dict.

This second lookup (and hash) are not needed and can be avoided by 
inlining a portion of PyDict_SetItem instead of calling the entire 
subroutine.

----------
components: Interpreter Core
messages: 85824
nosy: dschult
severity: normal
status: open
title: setdefault speedup
type: performance
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5730>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to