
On Sun, Jan 10, 2016 at 09:02:47PM +0100, Victor Stinner wrote:
2016-01-10 18:57 GMT+01:00 Steven D'Aprano <steve@pearwood.info>:
Do all custom Mappings need to implement __version__?
I believe the answer to that is No, but the PEP probably should clarify that.
In the PEP, I wrote "The PEP is designed to implement guards on namespaces, only the dict type can be used for namespaces in practice. collections.UserDict is modified because it must mimicks dict. collections.Mapping is unchanged." https://www.python.org/dev/peps/pep-0509/#changes
Is it enough? If no, what do you suggest to be more explicit?
You also should argue whether or not __version__ should be visible to users from pure Python, or only from C code (as Neil wants). In other words, should __version__ be part of the public API of dict, or an implementation detail? (1) Make __version__ part of the public API. Pros: - Simpler implementation? - Allows easier debugging. - Users can make use of it for their own purposes. Cons: - Neil wants to avoid users making use of this feature. (Why, he hasn't explained, or if he did, I missed it.) - All implementations (PyPy, Jython, etc.) must copy it. - You lock in one specific implementation for guards and cannot change to another one. (2) Keep __version__ private. Pros: - Other implementations can ignore it. - You can change the implementation for guards. Cons: - Users may resort to ctypes to make use of it. (If they can.) -- Steve