Add __hash__ to tgl.Peer.

This commit is contained in:
Vincent Castellano 2015-05-29 20:36:26 -07:00
parent c2bb5346df
commit cbe442b7c6

View File

@ -969,6 +969,12 @@ tgl_Peer_repr(tgl_Peer *self)
return ret; return ret;
} }
int
tgl_Peer_hash(PyObject *self)
{
return PyObject_Hash(PyObject_GetAttrString(self, "id"));
}
PyObject * PyObject *
tgl_Peer_RichCompare(PyObject *self, PyObject *other, int cmp) tgl_Peer_RichCompare(PyObject *self, PyObject *other, int cmp)
{ {
@ -1016,7 +1022,7 @@ PyTypeObject tgl_PeerType = {
0, /* tp_as_number */ 0, /* tp_as_number */
0, /* tp_as_sequence */ 0, /* tp_as_sequence */
0, /* tp_as_mapping */ 0, /* tp_as_mapping */
0, /* tp_hash */ (hashfunc)tgl_Peer_hash, /* tp_hash */
0, /* tp_call */ 0, /* tp_call */
0, /* tp_str */ 0, /* tp_str */
0, /* tp_getattro */ 0, /* tp_getattro */