Dan Schult added the comment:
Thank you... I stand corrected
That's actually very helpful!
Of course using defdict makes the default assignment take two hashes,
two lookups, an attribute/function lookup (__missing__) and the extra
function call, plus doesn't allow argume
Dan Schult added the comment:
On Apr 11, 2009, at 8:15 AM, Martin v. Löwis
@psf.upfronthosting.co.za
@psf.upfronthosting.co.za> wrote:
> Martin v. Löwis added the comment:
>
>> By the way, defaultdict is NOT like setdefault--it is like get().
>> Missing entries do n
Dan Schult added the comment:
Benchmarks:
Upon trying cooked up examples, I do not notice any speedup
beyond 5-10%. Seems like function calling time swamps everything
for small examples with fast hashes. I don't have a handy dandy
example with long hash times or long lookup times. T
Changes by Dan Schult :
--
keywords: +patch
Added file: http://bugs.python.org/file13665/dict_setdefault.patch
___
Python tracker
<http://bugs.python.org/issue5
New submission from Dan Schult :
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