Fix typos and tweak the return value of dict_get_version(d)

This commit is contained in:
Berker Peksag 2016-03-27 22:52:25 +03:00
parent 11e9267809
commit f730565241
2 changed files with 8 additions and 8 deletions

View File

@ -179,7 +179,7 @@ Example using an hypothetical ``dict_get_version(dict)`` function::
If a dictionary is created with items, the version is also incremented If a dictionary is created with items, the version is also incremented
at each dictionary insertion. Example:: at each dictionary insertion. Example::
>>> d=dict(x=7, y=33) >>> d = dict(x=7, y=33)
>>> dict_get_version(d) >>> dict_get_version(d)
2 2
@ -188,14 +188,14 @@ value. For efficiency, values are compared by their identity:
``new_value is old_value``, not by their content: ``new_value is old_value``, not by their content:
``new_value == old_value``. Example:: ``new_value == old_value``. Example::
>>> d={} >>> d = {}
>>> value = object() >>> value = object()
>>> d['key'] = value >>> d['key'] = value
>>> dict_get_version(d) >>> dict_get_version(d)
2 1
>>> d['key'] = value >>> d['key'] = value
>>> dict_get_version(d) >>> dict_get_version(d)
2 1
.. note:: .. note::
CPython uses some singleton like integers in the range [-5; 257], CPython uses some singleton like integers in the range [-5; 257],
@ -233,7 +233,7 @@ then continue to be incremented) according to the C standard.
After an integer overflow, a guard can succeed whereas the watched After an integer overflow, a guard can succeed whereas the watched
dictionary key was modified. The bug occurs if the dictionary is dictionary key was modified. The bug occurs if the dictionary is
modified at least ``2 ** 64`` times between two checks of the guard and modified at least ``2 ** 64`` times between two checks of the guard and
if the new version (theorical value with no integer overflow) is equal if the new version (theoretical value with no integer overflow) is equal
to the old version modulo ``2 ** 64``. to the old version modulo ``2 ** 64``.
If a dictionary is modified each nanosecond, an overflow takes longer If a dictionary is modified each nanosecond, an overflow takes longer
@ -373,7 +373,7 @@ expecting the exact ``dict`` type. Issues:
``PyObject_xxx()`` if the object is a ``dict`` subtype ``PyObject_xxx()`` if the object is a ``dict`` subtype
* ``PyDict_CheckExact()`` check fails on ``dict`` subtype, whereas some * ``PyDict_CheckExact()`` check fails on ``dict`` subtype, whereas some
functions require the exact ``dict`` type. functions require the exact ``dict`` type.
* ``Python/ceval.c`` does not completly supports dict subtypes for * ``Python/ceval.c`` does not completely supports dict subtypes for
namespaces namespaces

View File

@ -77,7 +77,7 @@ latest CPython stable version is 3.5, whereas PyPy only supports Python
Even if PyPy has a very good compatibility with Python, some modules are Even if PyPy has a very good compatibility with Python, some modules are
still not compatible with PyPy: see `PyPy Compatibility Wiki still not compatible with PyPy: see `PyPy Compatibility Wiki
<https://bitbucket.org/pypy/compatibility/wiki/Home>`_. The incomplete <https://bitbucket.org/pypy/compatibility/wiki/Home>`_. The incomplete
support of the the Python C API is part of this problem. There are also support of the Python C API is part of this problem. There are also
subtle differences between PyPy and CPython like reference counting: subtle differences between PyPy and CPython like reference counting:
object destructors are always called in PyPy, but can be called "later" object destructors are always called in PyPy, but can be called "later"
than in CPython. Using context managers helps to control when resources than in CPython. Using context managers helps to control when resources
@ -393,7 +393,7 @@ its index::
int PyFunction_RemoveSpecialized(PyObject *func, Py_ssize_t index) int PyFunction_RemoveSpecialized(PyObject *func, Py_ssize_t index)
Return ``0`` on sucess or if the index does not exist. Raise an exception and Return ``0`` on success or if the index does not exist. Raise an exception and
return ``-1`` on error. return ``-1`` on error.