Hi,

I've written a patch that adds a new C-API call for dict.setdefault(). The
reason is that there is currently no way to test for a key and insert a
fallback value for it without either evaluating the hash function twice or
calling through the Python function. Both may involve considerable overhead
and the double hash may have side-effects.

http://bugs.python.org/issue17327

It does not include an explicit test because it does not add any code over
the normal dict.setdefault() implementation, which is already tested at the
Python level. If you prefer having a dummy test that checks that the
function is there, I don't mind adding one.

Please comment and/or apply the patch.

Thanks,

Stefan

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to