From: Michael Tremer Date: Sun, 7 Jan 2024 18:08:14 +0000 (+0000) Subject: python: Make AS objects hashable X-Git-Tag: 0.9.18~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=227b44c2d9368e162e6e2faff1a5467fcac9225f;p=location%2Flibloc.git python: Make AS objects hashable Signed-off-by: Michael Tremer --- diff --git a/src/python/as.c b/src/python/as.c index 4cf9987..06ba5db 100644 --- a/src/python/as.c +++ b/src/python/as.c @@ -125,6 +125,12 @@ static PyObject* AS_richcompare(ASObject* self, ASObject* other, int op) { Py_RETURN_NOTIMPLEMENTED; } +static Py_hash_t AS_hash(ASObject* self) { + uint32_t number = loc_as_get_number(self->as); + + return number; +} + static struct PyGetSetDef AS_getsetters[] = { { "name", @@ -156,4 +162,5 @@ PyTypeObject ASType = { .tp_repr = (reprfunc)AS_repr, .tp_str = (reprfunc)AS_str, .tp_richcompare = (richcmpfunc)AS_richcompare, + .tp_hash = (hashfunc)AS_hash, };