summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-10-17 20:54:53 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-10-17 20:54:53 (GMT)
commit8f67d0893f7170986b0ad370844318544270cbcc (patch)
tree4aec6cf093d4d042d18d1fadc3ce52765d32bd8d /Doc/c-api
parent6fb457526cef485d64f4f6744d81cae8c02032b3 (diff)
downloadcpython-8f67d0893f7170986b0ad370844318544270cbcc.zip
cpython-8f67d0893f7170986b0ad370844318544270cbcc.tar.gz
cpython-8f67d0893f7170986b0ad370844318544270cbcc.tar.bz2
make hashes always the size of pointers; introduce Py_hash_t #9778
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/object.rst9
-rw-r--r--Doc/c-api/typeobj.rst8
2 files changed, 11 insertions, 6 deletions
diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
index 7efc0d2..8410934 100644
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -247,15 +247,20 @@ is considered sufficient for this determination.
*NULL* on failure.
-.. c:function:: long PyObject_Hash(PyObject *o)
+.. c:function:: Py_hash_t PyObject_Hash(PyObject *o)
.. index:: builtin: hash
Compute and return the hash value of an object *o*. On failure, return ``-1``.
This is the equivalent of the Python expression ``hash(o)``.
+ .. versionchanged:: 3.2
-.. c:function:: long PyObject_HashNotImplemented(PyObject *o)
+ The return type is now Py_hash_t. This is a signed integer the same size
+ as Py_ssize_t.
+
+
+.. c:function:: Py_hash_t PyObject_HashNotImplemented(PyObject *o)
Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``.
This function receives special treatment when stored in a ``tp_hash`` slot,
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index a25ca41..fe751c2 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -306,10 +306,10 @@ type objects) *must* have the :attr:`ob_size` field.
An optional pointer to a function that implements the built-in function
:func:`hash`.
- The signature is the same as for :c:func:`PyObject_Hash`; it must return a C
- long. The value ``-1`` should not be returned as a normal return value; when an
- error occurs during the computation of the hash value, the function should set
- an exception and return ``-1``.
+ The signature is the same as for :c:func:`PyObject_Hash`; it must return a
+ value of the type Py_hash_t. The value ``-1`` should not be returned as a
+ normal return value; when an error occurs during the computation of the hash
+ value, the function should set an exception and return ``-1``.
This field can be set explicitly to :c:func:`PyObject_HashNotImplemented` to
block inheritance of the hash method from a parent type. This is interpreted