/*static*/long PyXPCOM_TypeObject::Py_hash(PyObject *self) #endif { // We always return the value of the nsISupports *. nsISupports *pUnkThis; if (!Py_nsISupports::InterfaceFromPyObject(self, NS_GET_IID(nsISupports), &pUnkThis, PR_FALSE)) return -1; #if PY_VERSION_HEX >= 0x03020000 Py_hash_t ret = _Py_HashPointer(pUnkThis); #else long ret = _Py_HashPointer(pUnkThis); #endif pUnkThis->Release(); return ret; }
static Py_hash_t method_hash(PyMethodObject *a) { Py_hash_t x, y; if (a->im_self == NULL) x = _Py_HashPointer(Py_None); else x = _Py_HashPointer(a->im_self); y = PyObject_Hash(a->im_func); if (y == -1) return -1; x = x ^ y; if (x == -1) x = -2; return x; }
static Py_hash_t contextvar_generate_hash(void *addr, PyObject *name) { /* Take hash of `name` and XOR it with the object's addr. The structure of the tree is encoded in objects' hashes, which means that sufficiently similar hashes would result in tall trees with many Collision nodes. Which would, in turn, result in slower get and set operations. The XORing helps to ensure that: (1) sequentially allocated ContextVar objects have different hashes; (2) context variables with equal names have different hashes. */ Py_hash_t name_hash = PyObject_Hash(name); if (name_hash == -1) { return -1; } Py_hash_t res = _Py_HashPointer(addr) ^ name_hash; return res == -1 ? -2 : res; }
static Py_ssize_t meth_hash(MpFunctionObject *a) { Py_ssize_t x; x = _Py_HashPointer((void*)(a->m_func)); return x; }
static long func_hash(PyFunctionObject *f) { long h,x; h = PyObject_Hash(f->func_code); if (h == -1) return h; x = _Py_HashPointer(f->func_globals); if (x == -1) return x; h ^= x; if (h == -1) h = -2; return h; }
long PyObject_Hash(PyObject *v) { PyTypeObject *tp = v->ob_type; if (tp->tp_hash != NULL) return (*tp->tp_hash)(v); if (tp->tp_compare == NULL && RICHCOMPARE(tp) == NULL) { return _Py_HashPointer(v); /* Use address as hash value */ } /* If there's a cmp but no hash defined, the object can't be hashed */ PyErr_SetString(PyExc_TypeError, "unhashable type"); return -1; }
static long wrapper_hash(wrapperobject *wp) { int x, y; x = _Py_HashPointer(wp->descr); if (x == -1) return -1; y = PyObject_Hash(wp->self); if (y == -1) return -1; x = x ^ y; if (x == -1) x = -2; return x; }
static long meth_hash(PythonQtSignalFunctionObject *a) { long x,y; if (a->m_self == NULL) x = 0; else { x = PyObject_Hash(a->m_self); if (x == -1) return -1; } y = _Py_HashPointer((void*)(a->m_ml)); if (y == -1) return -1; x ^= y; if (x == -1) x = -2; return x; }
static Py_hash_t meth_hash(PyCFunctionObject *a) { Py_hash_t x, y; if (a->m_self == NULL) x = 0; else { x = PyObject_Hash(a->m_self); if (x == -1) return -1; } y = _Py_HashPointer((void*)(a->m_ml->ml_meth)); if (y == -1) return -1; x ^= y; if (x == -1) x = -2; return x; }
/* use for both array and group */ static Py_hash_t BPy_IDGroup_hash(BPy_IDProperty *self) { return _Py_HashPointer(self->prop); }
static long tp_hash(PyObject *self) { return _Py_HashPointer(((AddressObject *) self)->ptr); }
Py_uhash_t _Py_hashtable_hash_ptr(const void *key) { return (Py_uhash_t)_Py_HashPointer((void *)key); }