Commit 3154bef3 authored by Stefan Behnel's avatar Stefan Behnel

make Py_hash_t a known type

parent a15d2df8
......@@ -8,6 +8,8 @@ Latest
Features added
--------------
* ``Py_hash_t`` is a known type (used in CPython for hash values).
* ``PySlice_*()`` C-API functions are available from the ``cpython.slice``
module.
......
......@@ -2285,6 +2285,7 @@ special_basic_c_types = cython.declare(dict, {
# name : (signed, longness)
"Py_UNICODE" : (0, 0),
"Py_UCS4" : (0, 0),
"Py_hash_t" : (2, 0),
"Py_ssize_t" : (2, 0),
"ssize_t" : (2, 0),
"size_t" : (0, 0),
......
cimport cython
def assign_py_hash_t(x):
"""
>>> assign_py_hash_t(12)
12
>>> assign_py_hash_t(-12)
-12
"""
cdef Py_hash_t h = x
return h
def infer_hash_type(x):
"""
>>> infer_hash_type(123)
'Py_hash_t'
"""
h = hash(x)
return cython.typeof(h)
def assign_to_name(x):
"""
>>> assign_to_name(321)
321
"""
Py_hash_t = x
return Py_hash_t
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment