Generated by Cython 3.0.0a11

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: _ident.c

 01: # -*- coding: utf-8 -*-
 02: # Copyright 2018 gevent contributors. See LICENSE for details.
 03: # cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False
 04: 
 05: from __future__ import absolute_import
 06: from __future__ import division
 07: from __future__ import print_function
 08: 
 09: 
+10: from weakref import WeakKeyDictionary
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_INCREF(__pyx_n_s_WeakKeyDictionary);__Pyx_GIVEREF(__pyx_n_s_WeakKeyDictionary);PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_WeakKeyDictionary);__pyx_t_3 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_WeakKeyDictionary); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_INCREF(__pyx_t_2);__Pyx_XGOTREF(__pyx_v_6gevent_15_gevent_c_ident_WeakKeyDictionary);__Pyx_DECREF_SET(__pyx_v_6gevent_15_gevent_c_ident_WeakKeyDictionary, __pyx_t_2);__Pyx_GIVEREF(__pyx_t_2);__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+11: from weakref import ref
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__Pyx_INCREF(__pyx_n_s_ref);__Pyx_GIVEREF(__pyx_n_s_ref);PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_ref);__pyx_t_2 = __Pyx_Import(__pyx_n_s_weakref, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 12: 
+13: from heapq import heappop
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_INCREF(__pyx_n_s_heappop);__Pyx_GIVEREF(__pyx_n_s_heappop);PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_heappop);__pyx_t_3 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 13, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_heappop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_INCREF(__pyx_t_2);__Pyx_XGOTREF(__pyx_v_6gevent_15_gevent_c_ident_heappop);__Pyx_DECREF_SET(__pyx_v_6gevent_15_gevent_c_ident_heappop, __pyx_t_2);__Pyx_GIVEREF(__pyx_t_2);__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+14: from heapq import heappush
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__Pyx_INCREF(__pyx_n_s_heappush);__Pyx_GIVEREF(__pyx_n_s_heappush);PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_heappush);__pyx_t_2 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;__pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_heappush); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__Pyx_INCREF(__pyx_t_3);__Pyx_XGOTREF(__pyx_v_6gevent_15_gevent_c_ident_heappush);__Pyx_DECREF_SET(__pyx_v_6gevent_15_gevent_c_ident_heappush, __pyx_t_3);__Pyx_GIVEREF(__pyx_t_3);__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 15: 
+16: __all__ = [
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_INCREF(__pyx_n_s_IdentRegistry);__Pyx_GIVEREF(__pyx_n_s_IdentRegistry);PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_IdentRegistry);if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error)__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 17:     'IdentRegistry',
 18: ]
 19: 
 20: class ValuedWeakRef(ref):
 21:     """
 22:     A weak ref with an associated value.
 23:     """
 24: 
+25:     __slots__ = ('value',)
if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef->tp_dict, __pyx_n_s_slots, __pyx_tuple__3) < 0) __PYX_ERR(0, 25, __pyx_L1_error)PyType_Modified(__pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef);__pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_value); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 25, __pyx_L1_error)__Pyx_GOTREF(__pyx_tuple__3);__Pyx_GIVEREF(__pyx_tuple__3);
 26: 
 27: 
+28: class IdentRegistry(object):
struct __pyx_vtabstruct_6gevent_15_gevent_c_ident_IdentRegistry {PyObject *(*get_ident)(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *, PyObject *, int __pyx_skip_dispatch);PyObject *(*_return_ident)(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *, struct __pyx_obj_6gevent_15_gevent_c_ident_ValuedWeakRef *, int __pyx_skip_dispatch);};static struct __pyx_vtabstruct_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_vtabptr_6gevent_15_gevent_c_ident_IdentRegistry;
 29:     """
 30:     Maintains a unique mapping of (small) non-negative integer identifiers
 31:     to objects that can be weakly referenced.
 32: 
 33:     It is guaranteed that no two objects will have the the same
 34:     identifier at the same time, as long as those objects are
 35:     also uniquely hashable.
 36:     """
 37: 
+38:     def __init__(self):
/* Python wrapper */static int __pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/static int __pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {CYTHON_UNUSED const Py_ssize_t __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);int __pyx_r;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);if (unlikely(__pyx_nargs > 0)) {__Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, __pyx_nargs); return -1;}if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_VARARGS(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;__pyx_r = __pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry___init__(((struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *)__pyx_v_self));/* function exit code */__Pyx_RefNannyFinishContext();return __pyx_r;}static int __pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry___init__(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_v_self) {int __pyx_r;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("__init__", 0);/* function exit code */__pyx_r = 0;goto __pyx_L0;__pyx_L1_error:;__Pyx_XDECREF(__pyx_t_1);__Pyx_XDECREF(__pyx_t_2);__Pyx_XDECREF(__pyx_t_3);__Pyx_AddTraceback("gevent._gevent_c_ident.IdentRegistry.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);__pyx_r = -1;__pyx_L0:;__Pyx_RefNannyFinishContext();return __pyx_r;}
 39:         # {obj -> (ident, wref(obj))}
+40:         self._registry = WeakKeyDictionary()
__Pyx_INCREF(__pyx_v_6gevent_15_gevent_c_ident_WeakKeyDictionary);__pyx_t_2 = __pyx_v_6gevent_15_gevent_c_ident_WeakKeyDictionary; __pyx_t_3 = NULL;__pyx_t_4 = 0;if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);if (likely(__pyx_t_3)) {PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);__Pyx_INCREF(__pyx_t_3);__Pyx_INCREF(function);__Pyx_DECREF_SET(__pyx_t_2, function);__pyx_t_4 = 1;}}{PyObject *__pyx_callargs[1] = {__pyx_t_3, };__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_1);__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;}__Pyx_GIVEREF(__pyx_t_1);__Pyx_GOTREF(__pyx_v_self->_registry);__Pyx_DECREF(__pyx_v_self->_registry);__pyx_v_self->_registry = __pyx_t_1;__pyx_t_1 = 0;
 41: 
 42:         # A heap of numbers that have been used and returned
+43:         self._available_idents = []
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_1);__Pyx_GIVEREF(__pyx_t_1);__Pyx_GOTREF(__pyx_v_self->_available_idents);__Pyx_DECREF(__pyx_v_self->_available_idents);__pyx_v_self->_available_idents = ((PyObject*)__pyx_t_1);__pyx_t_1 = 0;
 44: 
+45:     def get_ident(self, obj):
static PyObject *__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/static PyObject *__pyx_f_6gevent_15_gevent_c_ident_13IdentRegistry_get_ident(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_v_self, PyObject *__pyx_v_obj, CYTHON_UNUSED int __pyx_skip_dispatch) {PyObject *__pyx_v_ident = NULL;struct __pyx_obj_6gevent_15_gevent_c_ident_ValuedWeakRef *__pyx_v_vref = NULL;PyObject *__pyx_r = NULL;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("get_ident", 0);/* function exit code */__pyx_L1_error:;__Pyx_XDECREF(__pyx_t_4);__Pyx_XDECREF(__pyx_t_5);__Pyx_XDECREF(__pyx_t_8);__Pyx_AddTraceback("gevent._gevent_c_ident.IdentRegistry.get_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);__pyx_r = 0;__pyx_L0:;__Pyx_XDECREF(__pyx_v_ident);__Pyx_XDECREF((PyObject *)__pyx_v_vref);__Pyx_XGIVEREF(__pyx_r);__Pyx_RefNannyFinishContext();return __pyx_r;}/* Python wrapper */static PyObject *__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/PyDoc_STRVAR(__pyx_doc_6gevent_15_gevent_c_ident_13IdentRegistry_2get_ident, "IdentRegistry.get_ident(self, obj)\n\n        Retrieve the identifier for *obj*, creating one\n        if necessary.\n        ");static PyMethodDef __pyx_mdef_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident = {"get_ident", (PyCFunction)__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident, METH_O, __pyx_doc_6gevent_15_gevent_c_ident_13IdentRegistry_2get_ident};static PyObject *__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) {CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);PyObject *__pyx_r = 0;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("get_ident (wrapper)", 0);__pyx_r = __pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry_2get_ident(((struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *)__pyx_v_self), ((PyObject *)__pyx_v_obj));/* function exit code */__Pyx_RefNannyFinishContext();return __pyx_r;}static PyObject *__pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry_2get_ident(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_v_self, PyObject *__pyx_v_obj) {PyObject *__pyx_r = NULL;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("get_ident", 0);__Pyx_XDECREF(__pyx_r);__pyx_t_1 = __pyx_f_6gevent_15_gevent_c_ident_13IdentRegistry_get_ident(__pyx_v_self, __pyx_v_obj, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_1);__pyx_r = __pyx_t_1;__pyx_t_1 = 0;goto __pyx_L0;/* function exit code */__pyx_L1_error:;__Pyx_XDECREF(__pyx_t_1);__Pyx_AddTraceback("gevent._gevent_c_ident.IdentRegistry.get_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);__pyx_r = NULL;__pyx_L0:;__Pyx_XGIVEREF(__pyx_r);__Pyx_RefNannyFinishContext();return __pyx_r;}__pyx_tuple__4 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 45, __pyx_L1_error)__Pyx_GOTREF(__pyx_tuple__4);__Pyx_GIVEREF(__pyx_tuple__4);__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_IdentRegistry_get_ident, NULL, __pyx_n_s_gevent__gevent_c_ident, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_15_gevent_c_ident_IdentRegistry->tp_dict, __pyx_n_s_get_ident, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;PyType_Modified(__pyx_ptype_6gevent_15_gevent_c_ident_IdentRegistry);__pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_gevent__ident_py, __pyx_n_s_get_ident, 45, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 45, __pyx_L1_error)
 46:         """
 47:         Retrieve the identifier for *obj*, creating one
 48:         if necessary.
 49:         """
 50: 
+51:         try:
{/*try:*/ {}__pyx_L3_error:;__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;__Pyx_XGIVEREF(__pyx_t_1);__Pyx_XGIVEREF(__pyx_t_2);__Pyx_XGIVEREF(__pyx_t_3);__Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);goto __pyx_L1_error;__pyx_L7_try_return:;__Pyx_XGIVEREF(__pyx_t_1);__Pyx_XGIVEREF(__pyx_t_2);__Pyx_XGIVEREF(__pyx_t_3);__Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);goto __pyx_L0;__pyx_L4_exception_handled:;__Pyx_XGIVEREF(__pyx_t_1);__Pyx_XGIVEREF(__pyx_t_2);__Pyx_XGIVEREF(__pyx_t_3);__Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);}
+52:             return self._registry[obj][0]
__Pyx_XDECREF(__pyx_r);__pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_self->_registry, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L3_error)__Pyx_GOTREF(__pyx_t_4);__pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 52, __pyx_L3_error)__Pyx_GOTREF(__pyx_t_5);__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;__pyx_r = __pyx_t_5;__pyx_t_5 = 0;goto __pyx_L7_try_return;
+53:         except KeyError:
__pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);if (__pyx_t_6) {__Pyx_ErrRestore(0,0,0);goto __pyx_L4_exception_handled;}goto __pyx_L5_except_error;__pyx_L5_except_error:;
 54:             pass
 55: 
+56:         if self._available_idents:
__pyx_t_7 = (__pyx_v_self->_available_idents != Py_None)&&(PyList_GET_SIZE(__pyx_v_self->_available_idents) != 0);if (__pyx_t_7) {goto __pyx_L9;}
 57:             # Take the smallest free number
+58:             ident = heappop(self._available_idents)
__Pyx_INCREF(__pyx_v_6gevent_15_gevent_c_ident_heappop);__pyx_t_4 = __pyx_v_6gevent_15_gevent_c_ident_heappop; __pyx_t_8 = NULL;__pyx_t_6 = 0;if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);if (likely(__pyx_t_8)) {PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);__Pyx_INCREF(__pyx_t_8);__Pyx_INCREF(function);__Pyx_DECREF_SET(__pyx_t_4, function);__pyx_t_6 = 1;}}{PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_self->_available_idents};__pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 58, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_5);__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;}__pyx_v_ident = __pyx_t_5;__pyx_t_5 = 0;
 59:         else:
 60:             # Allocate a bigger one
+61:             ident = len(self._registry)
/*else*/ {__pyx_t_5 = __pyx_v_self->_registry;__Pyx_INCREF(__pyx_t_5);__pyx_t_9 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 61, __pyx_L1_error)__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;__pyx_t_5 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_5);__pyx_v_ident = __pyx_t_5;__pyx_t_5 = 0;}__pyx_L9:;
 62: 
+63:         vref = ValuedWeakRef(obj, self._return_ident)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_return_ident); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_5);__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_4);__Pyx_INCREF(__pyx_v_obj);__Pyx_GIVEREF(__pyx_v_obj);PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_obj);__Pyx_GIVEREF(__pyx_t_5);PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);__pyx_t_5 = 0;__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_5);__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;__pyx_v_vref = ((struct __pyx_obj_6gevent_15_gevent_c_ident_ValuedWeakRef *)__pyx_t_5);__pyx_t_5 = 0;
+64:         vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init
__Pyx_INCREF(__pyx_v_ident);__Pyx_GIVEREF(__pyx_v_ident);__Pyx_GOTREF(__pyx_v_vref->value);__Pyx_DECREF(__pyx_v_vref->value);__pyx_v_vref->value = __pyx_v_ident;
+65:         self._registry[obj] = (ident, vref)
__pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_5);__Pyx_INCREF(__pyx_v_ident);__Pyx_GIVEREF(__pyx_v_ident);PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_ident);__Pyx_INCREF((PyObject *)__pyx_v_vref);__Pyx_GIVEREF((PyObject *)__pyx_v_vref);PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_vref));if (unlikely((PyObject_SetItem(__pyx_v_self->_registry, __pyx_v_obj, __pyx_t_5) < 0))) __PYX_ERR(0, 65, __pyx_L1_error)__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+66:         return ident
__Pyx_XDECREF(__pyx_r);__Pyx_INCREF(__pyx_v_ident);__pyx_r = __pyx_v_ident;goto __pyx_L0;
 67: 
+68:     def _return_ident(self, vref):
static PyObject *__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_vref); /*proto*/static PyObject *__pyx_f_6gevent_15_gevent_c_ident_13IdentRegistry__return_ident(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_v_self, struct __pyx_obj_6gevent_15_gevent_c_ident_ValuedWeakRef *__pyx_v_vref, CYTHON_UNUSED int __pyx_skip_dispatch) {PyObject *__pyx_r = NULL;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("_return_ident", 0);/* function exit code */__pyx_r = Py_None; __Pyx_INCREF(Py_None);goto __pyx_L0;__pyx_L1_error:;__Pyx_XDECREF(__pyx_t_2);__Pyx_XDECREF(__pyx_t_3);__Pyx_XDECREF(__pyx_t_4);__Pyx_AddTraceback("gevent._gevent_c_ident.IdentRegistry._return_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);__pyx_r = 0;__pyx_L0:;__Pyx_XGIVEREF(__pyx_r);__Pyx_RefNannyFinishContext();return __pyx_r;}/* Python wrapper */static PyObject *__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_vref); /*proto*/PyDoc_STRVAR(__pyx_doc_6gevent_15_gevent_c_ident_13IdentRegistry_4_return_ident, "IdentRegistry._return_ident(self, ValuedWeakRef vref)");static PyMethodDef __pyx_mdef_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident = {"_return_ident", (PyCFunction)__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident, METH_O, __pyx_doc_6gevent_15_gevent_c_ident_13IdentRegistry_4_return_ident};static PyObject *__pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident(PyObject *__pyx_v_self, PyObject *__pyx_v_vref) {CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);PyObject *__pyx_r = 0;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("_return_ident (wrapper)", 0);if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vref), __pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef, 1, "vref", 0))) __PYX_ERR(0, 68, __pyx_L1_error)__pyx_r = __pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry_4_return_ident(((struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *)__pyx_v_self), ((struct __pyx_obj_6gevent_15_gevent_c_ident_ValuedWeakRef *)__pyx_v_vref));int __pyx_lineno = 0;const char *__pyx_filename = NULL;int __pyx_clineno = 0;/* function exit code */goto __pyx_L0;__pyx_L1_error:;__pyx_r = NULL;__pyx_L0:;__Pyx_RefNannyFinishContext();return __pyx_r;}static PyObject *__pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry_4_return_ident(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_v_self, struct __pyx_obj_6gevent_15_gevent_c_ident_ValuedWeakRef *__pyx_v_vref) {PyObject *__pyx_r = NULL;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("_return_ident", 0);__Pyx_XDECREF(__pyx_r);__pyx_t_1 = __pyx_f_6gevent_15_gevent_c_ident_13IdentRegistry__return_ident(__pyx_v_self, __pyx_v_vref, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_1);__pyx_r = __pyx_t_1;__pyx_t_1 = 0;goto __pyx_L0;/* function exit code */__pyx_L1_error:;__Pyx_XDECREF(__pyx_t_1);__Pyx_AddTraceback("gevent._gevent_c_ident.IdentRegistry._return_ident", __pyx_clineno, __pyx_lineno, __pyx_filename);__pyx_r = NULL;__pyx_L0:;__Pyx_XGIVEREF(__pyx_r);__Pyx_RefNannyFinishContext();return __pyx_r;}__pyx_tuple__6 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_vref); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 68, __pyx_L1_error)__Pyx_GOTREF(__pyx_tuple__6);__Pyx_GIVEREF(__pyx_tuple__6);__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_IdentRegistry__return_ident, NULL, __pyx_n_s_gevent__gevent_c_ident, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);if (PyDict_SetItem((PyObject *)__pyx_ptype_6gevent_15_gevent_c_ident_IdentRegistry->tp_dict, __pyx_n_s_return_ident, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error)__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;PyType_Modified(__pyx_ptype_6gevent_15_gevent_c_ident_IdentRegistry);
 69:         # By the time this is called, self._registry has been
 70:         # updated
+71:         if heappush is not None:
__pyx_t_1 = (__pyx_v_6gevent_15_gevent_c_ident_heappush != Py_None);if (__pyx_t_1) {}
 72:             # Under some circumstances we can get called
 73:             # when the interpreter is shutting down, and globals
 74:             # aren't available any more.
+75:             heappush(self._available_idents, vref.value)
__Pyx_INCREF(__pyx_v_6gevent_15_gevent_c_ident_heappush);__pyx_t_3 = __pyx_v_6gevent_15_gevent_c_ident_heappush; __pyx_t_4 = NULL;__pyx_t_5 = 0;if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);if (likely(__pyx_t_4)) {PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);__Pyx_INCREF(__pyx_t_4);__Pyx_INCREF(function);__Pyx_DECREF_SET(__pyx_t_3, function);__pyx_t_5 = 1;}}{PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_self->_available_idents, __pyx_v_vref->value};__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5);__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;}__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 76: 
+77:     def __len__(self):
/* Python wrapper */static Py_ssize_t __pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_7__len__(PyObject *__pyx_v_self); /*proto*/static Py_ssize_t __pyx_pw_6gevent_15_gevent_c_ident_13IdentRegistry_7__len__(PyObject *__pyx_v_self) {CYTHON_UNUSED PyObject *const *__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);Py_ssize_t __pyx_r;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);__pyx_r = __pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry_6__len__(((struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *)__pyx_v_self));/* function exit code */__Pyx_RefNannyFinishContext();return __pyx_r;}static Py_ssize_t __pyx_pf_6gevent_15_gevent_c_ident_13IdentRegistry_6__len__(struct __pyx_obj_6gevent_15_gevent_c_ident_IdentRegistry *__pyx_v_self) {Py_ssize_t __pyx_r;__Pyx_RefNannyDeclarations__Pyx_RefNannySetupContext("__len__", 0);/* function exit code */__pyx_L1_error:;__Pyx_XDECREF(__pyx_t_1);__Pyx_AddTraceback("gevent._gevent_c_ident.IdentRegistry.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);__pyx_r = -1;__pyx_L0:;__Pyx_RefNannyFinishContext();return __pyx_r;}
+78:         return len(self._registry)
__pyx_t_1 = __pyx_v_self->_registry;__Pyx_INCREF(__pyx_t_1);__pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 78, __pyx_L1_error)__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;__pyx_r = __pyx_t_2;goto __pyx_L0;
 79: 
 80: 
+81: from gevent._util import import_c_accel
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_INCREF(__pyx_n_s_import_c_accel);__Pyx_GIVEREF(__pyx_n_s_import_c_accel);PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_import_c_accel);__pyx_t_3 = __Pyx_Import(__pyx_n_s_gevent__util, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_c_accel, __pyx_t_2) < 0) __PYX_ERR(0, 81, __pyx_L1_error)__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+82: import_c_accel(globals(), 'gevent.__ident')
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_import_c_accel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_3);__pyx_t_2 = __Pyx_Globals(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_4);__Pyx_GIVEREF(__pyx_t_2);PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);__Pyx_INCREF(__pyx_kp_s_gevent___ident);__Pyx_GIVEREF(__pyx_kp_s_gevent___ident);PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_kp_s_gevent___ident);__pyx_t_2 = 0;__pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)__Pyx_GOTREF(__pyx_t_2);__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;