This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dict.update.__doc__ is misleading
Type: Stage:
Components: Documentation Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, eric.araujo, ivank, r.david.murray, rhettinger
Priority: normal Keywords: patch

Created on 2010-10-30 02:34 by ivank, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dict.update.__doc__.patch ivank, 2010-10-30 02:34 mention fast path and .keys()
Messages (5)
msg119954 - (view) Author: ivank (ivank) Date: 2010-10-30 02:34
It would be nice if dict.update.__doc__ conveyed some of the subtleties of the update algorithm.  See the patch.  I changed __doc__ to mention the fast path for dicts, and changed one instance of E: -> E.keys():
msg119961 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-10-30 06:07
I'm not sure that we should mention the fast path for dicts.  That is an implementation detail and may not be present in IronPython, PyPy, Jython, etc.

The current version includes:

  D.updated(E, **F) --> None.  Updated D for dict/iterable E and F.

ISTM that covers the semantics of what it does.  Your proposed modification gets into how it does it.
msg119962 - (view) Author: ivank (ivank) Date: 2010-10-30 06:32
CPython's dict(obj) ignores `keys` and `__iter__` if obj is a subclass of dict.  I thought this was an important language detail, not just an implementation quirk.  But, I just tested pypy 1.3, and it is calling .keys() on dicts.  Oh well.

I think the __doc__ can still be slightly improved; ignore my patch and just change the first E: to E.keys(): - that would be more accurate.
msg119978 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-30 12:59
Maybe the fastpath should do a strict check and not be used for subclasses of dict?
msg214412 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-03-21 22:09
> Maybe the fastpath should do a strict check and not 
> be used for subclasses of dict?

This code is ancient and well-established.  IMO, nothing good can come from changing it (besides slowing down code that is already deployed and working fine).
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54449
2014-09-01 07:19:45rhettingersetstatus: open -> closed
resolution: rejected
2014-08-31 07:41:27berker.peksagsetnosy: - berker.peksag
2014-03-21 22:09:31rhettingersetassignee: docs@python -> rhettinger
messages: + msg214412
2014-03-21 08:54:34berker.peksagsetnosy: + berker.peksag, docs@python

assignee: docs@python
components: + Documentation, - Interpreter Core
versions: + Python 3.4, Python 3.5, - Python 3.1, Python 3.2
2010-11-02 19:02:18eric.araujosetnosy: + eric.araujo

versions: - Python 2.6, Python 2.5, Python 3.3
2010-10-30 12:59:48r.david.murraysetnosy: + r.david.murray
messages: + msg119978
2010-10-30 06:32:32ivanksetmessages: + msg119962
2010-10-30 06:07:24rhettingersetnosy: + rhettinger
messages: + msg119961
2010-10-30 02:34:06ivankcreate