Generated by Cython 3.1.2

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 -*-

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     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 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_WeakKeyDictionary); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_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_mstate_global->__pyx_n_u_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 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_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 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_heappop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_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_mstate_global->__pyx_n_u_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 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_heappush); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_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_mstate_global->__pyx_n_u_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 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_IdentRegistry); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_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 (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef, __pyx_mstate_global->__pyx_n_u_slots, __pyx_mstate_global->__pyx_tuple[0]) < 0) __PYX_ERR(0, 25, __pyx_L1_error)

     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 Py_ssize_t __pyx_nargs;
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      int __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
      #if CYTHON_ASSUME_SAFE_SIZE
      __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
      #else
      __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1;
      #endif
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, __pyx_nargs); return -1; }
      const Py_ssize_t __pyx_kwds_len = unlikely(__pyx_kwds) ? __Pyx_NumKwargs_VARARGS(__pyx_kwds) : 0;
      if (unlikely(__pyx_kwds_len < 0)) return -1;
      if (unlikely(__pyx_kwds_len > 0)) {__Pyx_RejectKeywords("__init__", __pyx_kwds); 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;
    /* … */
      /* 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_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_6gevent_15_gevent_c_ident_WeakKeyDictionary);
      __pyx_t_3 = __pyx_v_6gevent_15_gevent_c_ident_WeakKeyDictionary;
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_2);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__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_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;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_11);
      __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\nRetrieve the identifier for *obj*, creating one\nif necessary.");
    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;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("get_ident (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __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_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_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_15_gevent_c_ident_13IdentRegistry_3get_ident, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_IdentRegistry_get_ident, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_ident, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_6gevent_15_gevent_c_ident_IdentRegistry, __pyx_mstate_global->__pyx_n_u_get_ident, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     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_L5_except_error:;
        __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_PyLong_From_long, 0, 0, 1, 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;

     54:             pass

     55:

    +56:         if self._available_idents:

      __pyx_t_7 = (__pyx_v_self->_available_idents != Py_None)&&(__Pyx_PyList_GET_SIZE(__pyx_v_self->_available_idents) != 0);
      if (unlikely(((!CYTHON_ASSUME_SAFE_MACROS) && __pyx_t_7 < 0))) __PYX_ERR(0, 56, __pyx_L1_error)
      if (__pyx_t_7) {
    /* … */
        goto __pyx_L11;
      }

     57:             # Take the smallest free number

    +58:             ident = heappop(self._available_idents)

        __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_6gevent_15_gevent_c_ident_heappop);
        __pyx_t_8 = __pyx_v_6gevent_15_gevent_c_ident_heappop;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_self->_available_idents};
          __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__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_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_10 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 61, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_10); 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_L11:;

     62:

    +63:         vref = ValuedWeakRef(obj, self._return_ident)

      __pyx_t_8 = NULL;
      __Pyx_INCREF((PyObject *)__pyx_mstate_global->__pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef);
      __pyx_t_4 = ((PyObject *)__pyx_mstate_global->__pyx_ptype_6gevent_15_gevent_c_ident_ValuedWeakRef);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_mstate_global->__pyx_n_u_return_ident); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_9 = 1;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_v_obj, __pyx_t_11};
        __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
        __Pyx_GOTREF((PyObject *)__pyx_t_5);
      }
      __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);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_ident) != (0)) __PYX_ERR(0, 65, __pyx_L1_error);
      __Pyx_INCREF((PyObject *)__pyx_v_vref);
      __Pyx_GIVEREF((PyObject *)__pyx_v_vref);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_vref)) != (0)) __PYX_ERR(0, 65, __pyx_L1_error);
      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;
    /* … */
      /* 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;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_return_ident (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vref), __pyx_mstate_global->__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;
      goto __pyx_L5_cleaned_up;
      __pyx_L0:;
      __pyx_L5_cleaned_up:;
      __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_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_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gevent_15_gevent_c_ident_13IdentRegistry_5_return_ident, __Pyx_CYFUNCTION_CCLASS, __pyx_mstate_global->__pyx_n_u_IdentRegistry__return_ident, NULL, __pyx_mstate_global->__pyx_n_u_gevent__gevent_c_ident, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_SetItemOnTypeDict(__pyx_mstate_global->__pyx_ptype_6gevent_15_gevent_c_ident_IdentRegistry, __pyx_mstate_global->__pyx_n_u_return_ident, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     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_t_3 = NULL;
        __Pyx_INCREF(__pyx_v_6gevent_15_gevent_c_ident_heappush);
        __pyx_t_4 = __pyx_v_6gevent_15_gevent_c_ident_heappush;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_self->_available_idents, __pyx_v_vref->value};
          __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__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_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;
      Py_ssize_t __pyx_r;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
      __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
      __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;

    +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 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_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_mstate_global->__pyx_n_u_import_c_accel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_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_t_2 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_import_c_accel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_Globals(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = 1;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_t_5, __pyx_mstate_global->__pyx_kp_u_gevent___ident};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;