11// For background on the hashtable design first implemented in AutoMap, see the following:
22// https://github.com/brandtbucher/automap/blob/b787199d38d6bfa1b55484e5ea1e89b31cc1fa72/automap.c#L12
3-
4-
53# include <math.h>
4+ # include "stdbool.h"
5+
66# define PY_SSIZE_T_CLEAN
77# include "Python.h"
88
@@ -478,7 +478,7 @@ static void
478478fami_dealloc (FAMIObject * self )
479479{
480480 Py_DECREF (self -> fam );
481- Py_TYPE ( self ) -> tp_free ((PyObject * )self );
481+ PyObject_Del ((PyObject * )self );
482482}
483483
484484
@@ -545,7 +545,7 @@ fami_iternext(FAMIObject *self)
545545
546546
547547static PyObject *
548- fami___length_hint__ (FAMIObject * self )
548+ fami_length_hint (FAMIObject * self )
549549{
550550 Py_ssize_t len = Py_MAX (0 , self -> fam -> keys_size - self -> index );
551551 return PyLong_FromSsize_t (len );
@@ -556,15 +556,15 @@ static PyObject *fami_new(FAMObject *, ViewKind, int);
556556
557557
558558static PyObject *
559- fami___reversed__ (FAMIObject * self )
559+ fami_reversed (FAMIObject * self )
560560{
561561 return fami_new (self -> fam , self -> kind , !self -> reversed );
562562}
563563
564564
565565static PyMethodDef fami_methods [] = {
566- {"__length_hint__" , (PyCFunction )fami___length_hint__ , METH_NOARGS , NULL },
567- {"__reversed__" , (PyCFunction )fami___reversed__ , METH_NOARGS , NULL },
566+ {"__length_hint__" , (PyCFunction )fami_length_hint , METH_NOARGS , NULL },
567+ {"__reversed__" , (PyCFunction )fami_reversed , METH_NOARGS , NULL },
568568 {NULL },
569569};
570570
@@ -676,7 +676,7 @@ static void
676676famv_dealloc (FAMVObject * self )
677677{
678678 Py_DECREF (self -> fam );
679- Py_TYPE ( self ) -> tp_free ((PyObject * )self );
679+ PyObject_Del ((PyObject * )self );
680680}
681681
682682
@@ -688,14 +688,14 @@ famv_fami_new(FAMVObject *self)
688688
689689
690690static PyObject *
691- famv___length_hint__ (FAMVObject * self )
691+ famv_length_hint (FAMVObject * self )
692692{
693693 return PyLong_FromSsize_t (self -> fam -> keys_size );
694694}
695695
696696
697697static PyObject *
698- famv___reversed__ (FAMVObject * self )
698+ famv_reversed (FAMVObject * self )
699699{
700700 return fami_new (self -> fam , self -> kind , 1 );
701701}
@@ -734,8 +734,8 @@ famv_richcompare(FAMVObject *self, PyObject *other, int op)
734734
735735
736736static PyMethodDef famv_methods [] = {
737- {"__length_hint__" , (PyCFunction ) famv___length_hint__ , METH_NOARGS , NULL },
738- {"__reversed__" , (PyCFunction ) famv___reversed__ , METH_NOARGS , NULL },
737+ {"__length_hint__" , (PyCFunction ) famv_length_hint , METH_NOARGS , NULL },
738+ {"__reversed__" , (PyCFunction ) famv_reversed , METH_NOARGS , NULL },
739739 {"isdisjoint" , (PyCFunction ) famv_isdisjoint , METH_O , NULL },
740740 {NULL },
741741};
@@ -2302,21 +2302,21 @@ fam_iter(FAMObject *self)
23022302
23032303
23042304static PyObject *
2305- fam___getnewargs__ (FAMObject * self )
2305+ fam_getnewargs (FAMObject * self )
23062306{
23072307 return PyTuple_Pack (1 , self -> keys );
23082308}
23092309
23102310
23112311static PyObject *
2312- fam___reversed__ (FAMObject * self )
2312+ fam_reversed (FAMObject * self )
23132313{
23142314 return fami_new (self , KEYS , 1 );
23152315}
23162316
23172317
23182318static PyObject *
2319- fam___sizeof__ (FAMObject * self )
2319+ fam_sizeof (FAMObject * self )
23202320{
23212321 PyObject * listsizeof = PyObject_CallMethod (self -> keys , "__sizeof__" , NULL );
23222322 if (!listsizeof ) {
@@ -2635,7 +2635,7 @@ fam_richcompare(FAMObject *self, PyObject *other, int op)
26352635
26362636
26372637static PyObject *
2638- fam___getstate__ (FAMObject * self )
2638+ fam_getstate (FAMObject * self )
26392639{
26402640 PyObject * state = PyTuple_Pack (1 , self -> keys );
26412641 return state ;
@@ -2644,7 +2644,7 @@ fam___getstate__(FAMObject *self)
26442644
26452645// State returned here is a tuple of keys, suitable for usage as an `args` argument.
26462646static PyObject *
2647- fam___setstate__ (FAMObject * self , PyObject * state )
2647+ fam_setstate (FAMObject * self , PyObject * state )
26482648{
26492649 if (!PyTuple_CheckExact (state ) || !PyTuple_GET_SIZE (state )) {
26502650 PyErr_SetString (PyExc_ValueError , "Unexpected pickled object." );
@@ -2661,11 +2661,11 @@ fam___setstate__(FAMObject *self, PyObject *state)
26612661
26622662
26632663static PyMethodDef fam_methods [] = {
2664- {"__getnewargs__" , (PyCFunction ) fam___getnewargs__ , METH_NOARGS , NULL },
2665- {"__reversed__" , (PyCFunction ) fam___reversed__ , METH_NOARGS , NULL },
2666- {"__sizeof__" , (PyCFunction ) fam___sizeof__ , METH_NOARGS , NULL },
2667- {"__getstate__" , (PyCFunction ) fam___getstate__ , METH_NOARGS , NULL },
2668- {"__setstate__" , (PyCFunction ) fam___setstate__ , METH_O , NULL },
2664+ {"__getnewargs__" , (PyCFunction ) fam_getnewargs , METH_NOARGS , NULL },
2665+ {"__reversed__" , (PyCFunction ) fam_reversed , METH_NOARGS , NULL },
2666+ {"__sizeof__" , (PyCFunction ) fam_sizeof , METH_NOARGS , NULL },
2667+ {"__getstate__" , (PyCFunction ) fam_getstate , METH_NOARGS , NULL },
2668+ {"__setstate__" , (PyCFunction ) fam_setstate , METH_O , NULL },
26692669 {"get" , (PyCFunction ) fam_get , METH_VARARGS , NULL },
26702670 {"items" , (PyCFunction ) fam_items , METH_NOARGS , NULL },
26712671 {"keys" , (PyCFunction ) fam_keys , METH_NOARGS , NULL },
0 commit comments