*.c: Use Python `METH_NOARGS' methods where applicable.
[catacomb-python] / algorithms.c
index 31bd95b..4d4f5e2 100644 (file)
@@ -193,9 +193,9 @@ static PyObject *ksget_min(PyObject *me, void *hunoz)
 {
   PyObject *set = ((keyszset_pyobj *)me)->set;
   int i, n, y, x = -1;
-  n = PyTuple_Size(set);
+  n = PyTuple_GET_SIZE(set);
   for (i = 0; i < n; i++) {
-    y = PyInt_AsLong(PyTuple_GetItem(set, i));
+    y = PyInt_AS_LONG(PyTuple_GET_ITEM(set, i));
     if (x == -1 || y < x) x = y;
   }
   return (PyInt_FromLong(x));
@@ -205,52 +205,94 @@ static PyObject *ksget_max(PyObject *me, void *hunoz)
 {
   PyObject *set = ((keyszset_pyobj *)me)->set;
   int i, n, y, x = -1;
-  n = PyTuple_Size(set);
+  n = PyTuple_GET_SIZE(set);
   for (i = 0; i < n; i++) {
-    y = PyInt_AsLong(PyTuple_GetItem(set, i));
+    y = PyInt_AS_LONG(PyTuple_GET_ITEM(set, i));
     if (y > x) x = y;
   }
   return (PyInt_FromLong(x));
 }
 
-static PyMemberDef keysz_pymembers[] = {
+static const PyMemberDef keysz_pymembers[] = {
 #define MEMBERSTRUCT keysz_pyobj
 #define default dfl /* ugh! */
-  MEMBER(default, T_INT, READONLY, "KSZ.default -> default key size")
+  MEMBER(default, T_INT,  READONLY, "KSZ.default -> default key size")
 #undef default
 #undef MEMBERSTRUCT
   { 0 }
 };
 
-static PyGetSetDef keyszany_pygetset[] = {
+#define KSZCONVOP(op)                                                  \
+  static PyObject *kszmeth_##op(PyObject *me, PyObject *arg)           \
+  {                                                                    \
+    double x, y;                                                       \
+    if (!PyArg_ParseTuple(arg, "d:" #op, &x)) return (0);              \
+    y = keysz_##op(x);                                                 \
+    return (PyFloat_FromDouble(y));                                    \
+  }
+KSZCONVOP(fromdl)
+KSZCONVOP(fromschnorr)
+KSZCONVOP(fromif)
+KSZCONVOP(fromec)
+KSZCONVOP(todl)
+KSZCONVOP(toschnorr)
+KSZCONVOP(toif)
+KSZCONVOP(toec)
+#undef KSZCONVOP
+
+static const PyMethodDef keysz_pymethods[] = {
+#define METHNAME(name) kszmeth_##name
+  SMTH (fromdl,        "fromdl(N) -> M: "
+                   "convert integer discrete log field size to work factor")
+  SMTH (fromschnorr, "fromschnorr(N) -> M: "
+                               "convert Schnorr group order to work factor")
+  SMTH (fromif,        "fromif(N) -> M: "
+                "convert integer factorization problem size to work factor")
+  SMTH (fromec,        "fromec(N) -> M: "
+                        "convert elliptic curve group order to work factor")
+  SMTH (todl,          "todl(N) -> M: "
+                   "convert work factor to integer discrete log field size")
+  SMTH (toschnorr,     "toschnorr(N) -> M: "
+                               "convert work factor to Schnorr group order")
+  SMTH (toif,          "toif(N) -> M: "
+                "convert work factor to integer factorization problem size")
+  SMTH (toec,          "toec(N) -> M: "
+                        "convert work factor to elliptic curve group order")
+  SMTH (toec,          "toec(N) -> M: "
+                        "convert work factor to elliptic curve group order")
+#undef METHNAME
+  { 0 }
+};
+
+static const PyGetSetDef keyszany_pygetset[] = {
 #define GETSETNAME(op, name) ka##op##_##name
-  GET  (min,                   "KSZ.min -> smallest allowed key size")
-  GET  (max,                   "KSZ.max -> largest allowed key size")
+  GET  (min,           "KSZ.min -> smallest allowed key size")
+  GET  (max,           "KSZ.max -> largest allowed key size")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMemberDef keyszrange_pymembers[] = {
+static const PyMemberDef keyszrange_pymembers[] = {
 #define MEMBERSTRUCT keyszrange_pyobj
-  MEMBER(min, T_INT, READONLY, "KSZ.min -> smallest allowed key size")
-  MEMBER(max, T_INT, READONLY, "KSZ.max -> largest allowed key size")
-  MEMBER(mod, T_INT, READONLY,
-        "KSZ.mod -> key size must be a multiple of this")
+  MEMBER(min,  T_INT,    READONLY, "KSZ.min -> smallest allowed key size")
+  MEMBER(max,  T_INT,    READONLY, "KSZ.max -> largest allowed key size")
+  MEMBER(mod,  T_INT,    READONLY,
+                           "KSZ.mod -> key size must be a multiple of this")
 #undef MEMBERSTRUCT
   { 0 }
 };
 
-static PyGetSetDef keyszset_pygetset[] = {
+static const PyGetSetDef keyszset_pygetset[] = {
 #define GETSETNAME(op, name) ks##op##_##name
-  GET  (min,                   "KSZ.min -> smallest allowed key size")
-  GET  (max,                   "KSZ.max -> largest allowed key size")
+  GET  (min,           "KSZ.min -> smallest allowed key size")
+  GET  (max,           "KSZ.max -> largest allowed key size")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMemberDef keyszset_pymembers[] = {
+static const PyMemberDef keyszset_pymembers[] = {
 #define MEMBERSTRUCT keyszset_pyobj
-  MEMBER(set, T_OBJECT, READONLY,      "KSZ.set -> allowed key sizes")
+  MEMBER(set,  T_OBJECT, READONLY, "KSZ.set -> allowed key sizes")
 #undef MEMBERSTRUCT
   { 0 }
 };
@@ -280,7 +322,7 @@ static PyTypeObject keysz_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Key size constraints.  Abstract.",
+  "Key size constraints.  Abstract.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -288,8 +330,8 @@ static PyTypeObject keysz_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  0,                                   /* @tp_methods@ */
-  keysz_pymembers,                     /* @tp_members@ */
+  PYMETHODS(keysz),                    /* @tp_methods@ */
+  PYMEMBERS(keysz),                    /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -328,8 +370,8 @@ static PyTypeObject keyszany_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"KeySZAny(DEFAULT)\n\
-  Key size constraints.  This object imposes no constraints on size.",
+  "KeySZAny(DEFAULT)\n"
+  "  Key size constraints.  This object imposes no constraints on size.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -339,7 +381,7 @@ static PyTypeObject keyszany_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  keyszany_pygetset,                   /* @tp_getset@ */
+  PYGETSET(keyszany),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -377,9 +419,9 @@ static PyTypeObject keyszrange_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"KeySZRange(DEFAULT, [min = 0], [max = 0], [mod = 1])\n\
-  Key size constraints.  Key size must be between MIN and MAX inclusive,\n\
-  and be a multiple of MOD.",
+  "KeySZRange(DEFAULT, [min = 0], [max = 0], [mod = 1])\n"
+  "  Key size constraints: size must be between MIN and MAX inclusive, and\n"
+   be a multiple of MOD.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -388,7 +430,7 @@ static PyTypeObject keyszrange_pytype_skel = {
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
-  keyszrange_pymembers,                        /* @tp_members@ */
+  PYMEMBERS(keyszrange),               /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
@@ -427,8 +469,8 @@ static PyTypeObject keyszset_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"KeySZSet(DEFAULT, SEQ)\n\
-  Key size constraints.  Key size must be DEFAULT or one in SEQ.",
+  "KeySZSet(DEFAULT, SEQ)\n"
+  "  Key size constraints: size must be DEFAULT or an element of SEQ.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -437,8 +479,8 @@ static PyTypeObject keyszset_pytype_skel = {
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
-  keyszset_pymembers,                  /* @tp_members@ */
-  keyszset_pygetset,                   /* @tp_getset@ */
+  PYMEMBERS(keyszset),                 /* @tp_members@ */
+  PYGETSET(keyszset),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -451,24 +493,6 @@ static PyTypeObject keyszset_pytype_skel = {
   0                                    /* @tp_is_gc@ */
 };
 
-#define KSZCONVOP(op)                                                  \
-  static PyObject *meth__KeySZ_##op(PyObject *me, PyObject *arg)       \
-  {                                                                    \
-    double x, y;                                                       \
-    if (!PyArg_ParseTuple(arg, "Od:" #op, &me, &x)) return (0);                \
-    y = keysz_##op(x);                                                 \
-    return (PyFloat_FromDouble(y));                                    \
-  }
-KSZCONVOP(fromdl)
-KSZCONVOP(fromschnorr)
-KSZCONVOP(fromif)
-KSZCONVOP(fromec)
-KSZCONVOP(todl)
-KSZCONVOP(toschnorr)
-KSZCONVOP(toif)
-KSZCONVOP(toec)
-#undef KSZCONVOP
-
 /*----- Symmetric encryption ----------------------------------------------*/
 
 static PyTypeObject *gccipher_pytype, *gcipher_pytype;
@@ -616,9 +640,8 @@ end:
   return (0);
 }
 
-static PyObject *gcmeth_bdry(PyObject *me, PyObject *arg)
+static PyObject *gcmeth_bdry(PyObject *me)
 {
-  if (!PyArg_ParseTuple(arg, ":bdry")) goto end;
   if (!GCIPHER_C(me)->ops->bdry) VALERR("`bdry' not supported");
   if (!GC_CLASS(GCIPHER_C(me))->blksz) VALERR("not a block cipher mode");
   GC_BDRY(GCIPHER_C(me));
@@ -627,23 +650,23 @@ end:
   return (0);
 }
 
-static PyGetSetDef gccipher_pygetset[] = {
+static const PyGetSetDef gccipher_pygetset[] = {
 #define GETSETNAME(op, name) gcc##op##_##name
-  GET  (keysz,                 "CC.keysz -> acceptable key sizes")
-  GET  (blksz,                 "CC.blksz -> block size, or zero")
-  GET  (name,                  "CC.name -> name of this kind of cipher")
+  GET  (keysz,         "CC.keysz -> acceptable key sizes")
+  GET  (blksz,         "CC.blksz -> block size, or zero")
+  GET  (name,          "CC.name -> name of this kind of cipher")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef gcipher_pymethods[] = {
+static const PyMethodDef gcipher_pymethods[] = {
 #define METHNAME(name) gcmeth_##name
-  METH (encrypt,               "C.encrypt(PT) -> CT")
-  METH (enczero,               "C.enczero(N) -> CT")
-  METH (decrypt,               "C.decrypt(CT) -> PT")
-  METH (deczero,               "C.deczero(N) -> PT")
-  METH (setiv,                 "C.setiv(IV)")
-  METH (bdry,                  "C.bdry()")
+  METH (encrypt,       "C.encrypt(PT) -> CT")
+  METH (enczero,       "C.enczero(N) -> CT")
+  METH (decrypt,       "C.decrypt(CT) -> PT")
+  METH (deczero,       "C.deczero(N) -> PT")
+  METH (setiv,         "C.setiv(IV)")
+  NAMETH(bdry,         "C.bdry()")
 #undef METHNAME
   { 0 }
 };
@@ -673,7 +696,7 @@ static PyTypeObject gccipher_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Symmetric cipher metaclass.",
+  "Symmetric cipher metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -683,7 +706,7 @@ static PyTypeObject gccipher_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gccipher_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gccipher),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -721,7 +744,7 @@ static PyTypeObject gcipher_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Symmetric cipher, abstract base class.",
+  "Symmetric cipher, abstract base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -729,7 +752,7 @@ static PyTypeObject gcipher_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gcipher_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(gcipher),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -938,26 +961,25 @@ static PyObject *gcaeget_ohd(PyObject *me, void *hunoz)
 static PyObject *gcaeget_flags(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GCAEAD_AEC(me)->f)); }
 
-static PyGetSetDef gcaead_pygetset[] = {
+static const PyGetSetDef gcaead_pygetset[] = {
 #define GETSETNAME(op, name) gcae##op##_##name
-  GET  (keysz,                 "AEC.keysz -> acceptable key sizes")
-  GET  (noncesz,               "AEC.noncesz -> acceptable nonce sizes")
-  GET  (tagsz,                 "AEC.tagsz -> acceptable tag sizes")
-  GET  (blksz,                 "AEC.blksz -> block size, or zero")
-  GET  (bufsz,                 "AEC.bufsz -> amount of data buffered internally")
-  GET  (ohd,                   "AEC.ohd -> maximum encryption overhead")
-  GET  (name,                  "AEC.name -> name of this kind of AEAD scheme")
-  GET  (flags,                 "AEC.flags -> mask of `AEADF_...' flags")
+  GET  (keysz,         "AEC.keysz -> acceptable key sizes")
+  GET  (noncesz,       "AEC.noncesz -> acceptable nonce sizes")
+  GET  (tagsz,         "AEC.tagsz -> acceptable tag sizes")
+  GET  (blksz,         "AEC.blksz -> block size, or zero")
+  GET  (bufsz,         "AEC.bufsz -> amount of data buffered internally")
+  GET  (ohd,           "AEC.ohd -> maximum encryption overhead")
+  GET  (name,          "AEC.name -> name of this kind of AEAD scheme")
+  GET  (flags,         "AEC.flags -> mask of `AEADF_...' flags")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyObject *gaekmeth_aad(PyObject *me, PyObject *arg)
+static PyObject *gaekmeth_aad(PyObject *me)
 {
   const gaead_key *k = GAEADKEY_K(me);
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTuple(arg, ":aad")) return (0);
   if (k->ops->c->f&AEADF_AADNDEP)
     VALERR("aad must be associated with enc/dec op");
   rc = gaeadaad_pywrap((PyObject *)GCAEAD_AAD(me->ob_type),
@@ -1042,11 +1064,11 @@ end:
   return (rc);
 }
 
-static PyMethodDef gaeadkey_pymethods[] = {
+static const PyMethodDef gaeadkey_pymethods[] = {
 #define METHNAME(name) gaekmeth_##name
-  METH  (aad,                  "KEY.aad() -> AAD")
-  KWMETH(enc,                  "KEY.enc(NONCE, [hsz], [msz], [tsz]) -> ENC")
-  KWMETH(dec,                  "KEY.dec(NONCE, [hsz], [csz], [tsz]) -> DEC")
+  NAMETH(aad,          "KEY.aad() -> AAD")
+  KWMETH(enc,          "KEY.enc(NONCE, [hsz], [msz], [tsz]) -> ENC")
+  KWMETH(dec,          "KEY.dec(NONCE, [hsz], [csz], [tsz]) -> DEC")
 #undef METHNAME
   { 0 }
 };
@@ -1100,19 +1122,18 @@ static PyObject *gaeaget_hsz(PyObject *me, void *hunoz)
 static PyObject *gaeaget_hlen(PyObject *me, void *hunoz)
   { return (gaea_check(me) ? 0 : getulong(GAEADAAD_HLEN(me))); }
 
-static PyGetSetDef gaeadaad_pygetset[] = {
+static const PyGetSetDef gaeadaad_pygetset[] = {
 #define GETSETNAME(op, name) gaea##op##_##name
-  GET  (hsz,                   "AAD.hsz -> precommitted header length or `None'")
-  GET  (hlen,                  "AAD.hlen -> header length so far")
+  GET  (hsz,           "AAD.hsz -> precommitted header length or `None'")
+  GET  (hlen,          "AAD.hlen -> header length so far")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyObject *gaeameth_copy(PyObject *me, PyObject *arg)
+static PyObject *gaeameth_copy(PyObject *me)
 {
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTuple(arg, ":copy")) goto end;
   if (gaea_check(me)) goto end;
   if (GAEADAAD_F(me)&AEADF_AADNDEP)
     VALERR("can't duplicate nonce-dependent aad");
@@ -1181,17 +1202,17 @@ static PyObject *gaeameth_hashstrz(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyMethodDef gaeadaad_pymethods[] = {
+static const PyMethodDef gaeadaad_pymethods[] = {
 #define METHNAME(name) gaeameth_##name
-  METH  (copy,                 "AAD.copy() -> AAD'")
-  METH  (hash,                 "AAD.hash(H)")
+  NAMETH(copy,         "AAD.copy() -> AAD'")
+  METH (hash,          "AAD.hash(H)")
 #define METHU_(n, W, w) METH(hashu##w, "AAD.hashu" #w "(WORD)")
   DOUINTCONV(METHU_)
 #undef METHU_
 #define METHBUF_(n, W, w) METH(hashbuf##w, "AAD.hashbuf" #w "(BYTES)")
   DOUINTCONV(METHBUF_)
 #undef METHBUF_
-  METH  (hashstrz,             "AAD.hashstrz(STRING)")
+  METH (hashstrz,      "AAD.hashstrz(STRING)")
 #undef METHNAME
   { 0 }
 };
@@ -1237,22 +1258,21 @@ static PyObject *gaeeget_tsz(PyObject *me, void *hunoz)
 static PyObject *gaeeget_mlen(PyObject *me, void *hunoz)
   { return getulong(GAEADENC_MLEN(me)); }
 
-static PyGetSetDef gaeadenc_pygetset[] = {
+static const PyGetSetDef gaeadenc_pygetset[] = {
 #define GETSETNAME(op, name) gaee##op##_##name
-  GET  (hsz,                   "ENC.hsz -> precommitted header length or `None'")
-  GET  (msz,                   "ENC.msz -> precommitted message length or `None'")
-  GET  (tsz,                   "ENC.tsz -> precommitted tag length or `None'")
-  GET  (mlen,                  "ENC.mlen -> message length so far")
+  GET  (hsz,           "ENC.hsz -> precommitted header length or `None'")
+  GET  (msz,           "ENC.msz -> precommitted message length or `None'")
+  GET  (tsz,           "ENC.tsz -> precommitted tag length or `None'")
+  GET  (mlen,          "ENC.mlen -> message length so far")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyObject *gaeemeth_aad(PyObject *me, PyObject *arg)
+static PyObject *gaeemeth_aad(PyObject *me)
 {
   gaeadenc_pyobj *ge = (gaeadenc_pyobj *)me;
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTuple(arg, ":aad")) return (0);
   if (!(ge->f&AEADF_AADNDEP))
     rc = gaeadaad_pywrap((PyObject *)GCAEADENC_KEY(ge->ob_type)->aad,
                         GAEAD_AAD(ge->e), 0, 0);
@@ -1362,12 +1382,12 @@ end:
   return (rc);
 }
 
-static PyMethodDef gaeadenc_pymethods[] = {
+static const PyMethodDef gaeadenc_pymethods[] = {
 #define METHNAME(name) gaeemeth_##name
-  METH  (aad,                  "ENC.aad() -> AAD")
-  KWMETH(reinit,               "ENC.reinit(NONCE, [hsz], [msz], [tsz])")
-  METH  (encrypt,              "ENC.encrypt(MSG) -> CT")
-  KWMETH(done,                 "ENC.done([tsz], [aad]) -> CT, TAG")
+  NAMETH(aad,          "ENC.aad() -> AAD")
+  KWMETH(reinit,       "ENC.reinit(NONCE, [hsz], [msz], [tsz])")
+  METH (encrypt,       "ENC.encrypt(MSG) -> CT")
+  KWMETH(done,         "ENC.done([tsz], [aad]) -> CT, TAG")
 #undef METHNAME
   { 0 }
 };
@@ -1412,21 +1432,20 @@ static PyObject *gaedget_tsz(PyObject *me, void *hunoz)
 static PyObject *gaedget_clen(PyObject *me, void *hunoz)
   { return getulong(GAEADDEC_CLEN(me)); }
 
-static PyGetSetDef gaeaddec_pygetset[] = {
+static const PyGetSetDef gaeaddec_pygetset[] = {
 #define GETSETNAME(op, name) gaed##op##_##name
-  GET  (hsz,                   "DEC.hsz -> precommitted header length or `None'")
-  GET  (csz,                   "DEC.csz -> precommitted ciphertext length or `None'")
-  GET  (tsz,                   "DEC.tsz -> precommitted tag length or `None'")
-  GET  (clen,                  "DEC.clen -> ciphertext length so far")
+  GET  (hsz,           "DEC.hsz -> precommitted header length or `None'")
+  GET  (csz,          "DEC.csz -> precommitted ciphertext length or `None'")
+  GET  (tsz,           "DEC.tsz -> precommitted tag length or `None'")
+  GET  (clen,          "DEC.clen -> ciphertext length so far")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyObject *gaedmeth_aad(PyObject *me, PyObject *arg)
+static PyObject *gaedmeth_aad(PyObject *me)
 {
   gaeaddec_pyobj *gd = (gaeaddec_pyobj *)me;
 
-  if (!PyArg_ParseTuple(arg, ":aad")) return (0);
   if (!(gd->f&AEADF_AADNDEP))
     return (gaeadaad_pywrap((PyObject *)GCAEADDEC_KEY(gd->ob_type)->aad,
                            GAEAD_AAD(gd->d), 0, 0));
@@ -1525,12 +1544,12 @@ end:
   return (rc);
 }
 
-static PyMethodDef gaeaddec_pymethods[] = {
+static const PyMethodDef gaeaddec_pymethods[] = {
 #define METHNAME(name) gaedmeth_##name
-  METH  (aad,                  "DEC.aad() -> AAD")
-  KWMETH(reinit,               "DEC.reinit(NONCE, [hsz], [csz], [tsz])")
-  METH  (decrypt,              "DEC.decrypt(CT) -> MSG")
-  KWMETH(done,                 "DEC.done(TAG, [aad]) -> MSG | None")
+  NAMETH(aad,          "DEC.aad() -> AAD")
+  KWMETH(reinit,       "DEC.reinit(NONCE, [hsz], [csz], [tsz])")
+  METH (decrypt,       "DEC.decrypt(CT) -> MSG")
+  KWMETH(done,         "DEC.done(TAG, [aad]) -> MSG | None")
 #undef METHNAME
   { 0 }
 };
@@ -1560,7 +1579,7 @@ static PyTypeObject gcaead_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated encryption (key) metaclass.",
+  "Authenticated encryption (key) metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1570,7 +1589,7 @@ static PyTypeObject gcaead_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gcaead_pygetset,                     /* @tp_getset@ */
+  PYGETSET(gcaead),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1608,7 +1627,7 @@ static PyTypeObject gaeadkey_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated encryption key.",
+  "Authenticated encryption key.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1616,7 +1635,7 @@ static PyTypeObject gaeadkey_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeadkey_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeadkey),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -1656,7 +1675,7 @@ static PyTypeObject gcaeadaad_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated encryption additional-data hash metaclass.",
+  "Authenticated encryption additional-data hash metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1704,7 +1723,7 @@ static PyTypeObject gaeadaad_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated encryption AAD hash.",
+  "Authenticated encryption AAD hash.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1712,9 +1731,9 @@ static PyTypeObject gaeadaad_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeadaad_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeadaad),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gaeadaad_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gaeadaad),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1752,7 +1771,7 @@ static PyTypeObject gcaeadenc_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated encryption operation metaclass.",
+  "Authenticated encryption operation metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1800,7 +1819,7 @@ static PyTypeObject gaeadenc_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated encryption operation.",
+  "Authenticated encryption operation.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1808,9 +1827,9 @@ static PyTypeObject gaeadenc_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeadenc_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeadenc),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gaeadenc_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gaeadenc),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1848,7 +1867,7 @@ static PyTypeObject gcaeaddec_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated decryption operation metaclass.",
+  "Authenticated decryption operation metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1896,7 +1915,7 @@ static PyTypeObject gaeaddec_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Authenticated decryption operation.",
+  "Authenticated decryption operation.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -1904,9 +1923,9 @@ static PyTypeObject gaeaddec_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gaeaddec_pymethods,                  /* @tp_methods@ */
+  PYMETHODS(gaeaddec),                 /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gaeaddec_pygetset,                   /* @tp_getset@ */
+  PYGETSET(gaeaddec),                  /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1989,11 +2008,8 @@ static PyObject *gchget_hashsz(PyObject *me, void *hunoz)
 static PyObject *gchget_bufsz(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GCHASH_CH(me)->bufsz)); }
 
-static PyObject *ghmeth_copy(PyObject *me, PyObject *arg)
-{
-  if (!PyArg_ParseTuple(arg, ":copy")) return (0);
-  return (ghash_pywrap((PyObject *)me->ob_type, GH_COPY(GHASH_H(me))));
-}
+static PyObject *ghmeth_copy(PyObject *me)
+  { return (ghash_pywrap((PyObject *)me->ob_type, GH_COPY(GHASH_H(me)))); }
 
 static PyObject *ghmeth_hash(PyObject *me, PyObject *arg)
 {
@@ -2036,11 +2052,10 @@ static PyObject *ghmeth_hashstrz(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyObject *ghmeth_done(PyObject *me, PyObject *arg)
+static PyObject *ghmeth_done(PyObject *me)
 {
   ghash *g;
   PyObject *rc;
-  if (!PyArg_ParseTuple(arg, ":done")) return (0);
   g = GH_COPY(GHASH_H(me));
   rc = bytestring_pywrap(0, g->ops->c->hashsz);
   GH_DONE(g, PyString_AS_STRING(rc));
@@ -2048,27 +2063,27 @@ static PyObject *ghmeth_done(PyObject *me, PyObject *arg)
   return (rc);
 }
 
-static PyGetSetDef gchash_pygetset[] = {
+static const PyGetSetDef gchash_pygetset[] = {
 #define GETSETNAME(op, name) gch##op##_##name
-  GET  (bufsz,                 "CH.bufsz -> hash buffer size, or zero")
-  GET  (hashsz,                "CH.hashsz -> hash output size")
-  GET  (name,                  "CH.name -> name of this kind of hash")
+  GET  (bufsz,         "CH.bufsz -> hash buffer size, or zero")
+  GET  (hashsz,        "CH.hashsz -> hash output size")
+  GET  (name,          "CH.name -> name of this kind of hash")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef ghash_pymethods[] = {
+static const PyMethodDef ghash_pymethods[] = {
 #define METHNAME(name) ghmeth_##name
-  METH (copy,                  "H.copy() -> HH")
-  METH (hash,                  "H.hash(M)")
+  NAMETH(copy,         "H.copy() -> HH")
+  METH (hash,          "H.hash(M)")
 #define METHU_(n, W, w) METH(hashu##w, "H.hashu" #w "(WORD)")
   DOUINTCONV(METHU_)
 #undef METHU_
 #define METHBUF_(n, W, w) METH(hashbuf##w, "H.hashbuf" #w "(BYTES)")
   DOUINTCONV(METHBUF_)
 #undef METHBUF_
-  METH (hashstrz,              "H.hashstrz(STRING)")
-  METH (done,                  "H.done() -> HASH")
+  METH (hashstrz,      "H.hashstrz(STRING)")
+  NAMETH(done,         "H.done() -> HASH")
 #undef METHNAME
   { 0 }
 };
@@ -2098,7 +2113,7 @@ static PyTypeObject gchash_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Hash function metaclass.",
+  "Hash function metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2108,7 +2123,7 @@ static PyTypeObject gchash_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gchash_pygetset,                     /* @tp_getset@ */
+  PYGETSET(gchash),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2146,7 +2161,7 @@ static PyTypeObject ghash_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Hash function, abstract base class.",
+  "Hash function, abstract base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2154,7 +2169,7 @@ static PyTypeObject ghash_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ghash_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(ghash),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -2278,11 +2293,11 @@ static PyObject *gcmget_keysz(PyObject *me, void *hunoz)
 static PyObject *gcmget_tagsz(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(GCMAC_CM(me)->hashsz)); }
 
-static PyGetSetDef gcmac_pygetset[] = {
+static const PyGetSetDef gcmac_pygetset[] = {
 #define GETSETNAME(op, name) gcm##op##_##name
-  GET  (keysz,                 "CM.keysz -> acceptable key sizes")
-  GET  (tagsz,                 "CM.tagsz -> MAC output size")
-  GET  (name,                  "CM.name -> name of this kind of MAC")
+  GET  (keysz,         "CM.keysz -> acceptable key sizes")
+  GET  (tagsz,         "CM.tagsz -> MAC output size")
+  GET  (name,          "CM.name -> name of this kind of MAC")
 #undef GETSETNAME
   { 0 }
 };
@@ -2312,7 +2327,7 @@ static PyTypeObject gcmac_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Message authentication code metametaclass.",
+  "Message authentication code metametaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2322,7 +2337,7 @@ static PyTypeObject gcmac_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gcmac_pygetset,                      /* @tp_getset@ */
+  PYGETSET(gcmac),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2360,7 +2375,7 @@ static PyTypeObject gmac_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Message authentication code metaclass, abstract base class.",
+  "Message authentication code metaclass, abstract base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2408,7 +2423,7 @@ static PyTypeObject gmhash_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Message authentication code, abstract base class.",
+  "Message authentication code, abstract base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2518,10 +2533,9 @@ static PyObject *poly1305clsget_masksz(PyObject *me, void *hunoz)
 static PyObject *poly1305clsget_tagsz(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(POLY1305_TAGSZ)); }
 
-static PyObject *polymeth_copy(PyObject *me, PyObject *arg)
+static PyObject *polymeth_copy(PyObject *me)
 {
   poly1305hash_pyobj *ph;
-  if (!PyArg_ParseTuple(arg, ":copy")) return (0);
   ph = PyObject_NEW(poly1305hash_pyobj, me->ob_type);
   poly1305_copy(&ph->ctx, P1305_CTX(me));
   Py_INCREF(me->ob_type);
@@ -2572,19 +2586,11 @@ static PyObject *polymeth_hashstrz(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyObject *polymeth_flush(PyObject *me, PyObject *arg)
-{
-  if (!PyArg_ParseTuple(arg, ":flush")) return (0);
-  poly1305_flush(P1305_CTX(me));
-  RETURN_ME;
-}
+static PyObject *polymeth_flush(PyObject *me)
+  { poly1305_flush(P1305_CTX(me)); RETURN_ME; }
 
-static PyObject *polymeth_flushzero(PyObject *me, PyObject *arg)
-{
-  if (!PyArg_ParseTuple(arg, ":flushzero")) return (0);
-  poly1305_flushzero(P1305_CTX(me));
-  RETURN_ME;
-}
+static PyObject *polymeth_flushzero(PyObject *me)
+  { poly1305_flushzero(P1305_CTX(me)); RETURN_ME; }
 
 static PyObject *polymeth_concat(PyObject *me, PyObject *arg)
 {
@@ -2602,10 +2608,9 @@ end:
   return (0);
 }
 
-static PyObject *polymeth_done(PyObject *me, PyObject *arg)
+static PyObject *polymeth_done(PyObject *me)
 {
   PyObject *rc;
-  if (!PyArg_ParseTuple(arg, ":done")) return (0);
   if (!(P1305_F(me) & f_mask)) VALERR("no mask");
   rc = bytestring_pywrap(0, POLY1305_TAGSZ);
   poly1305_done(P1305_CTX(me), PyString_AS_STRING(rc));
@@ -2614,31 +2619,31 @@ end:
   return (0);
 }
 
-static PyGetSetDef poly1305cls_pygetset[] = {
+static const PyGetSetDef poly1305cls_pygetset[] = {
 #define GETSETNAME(op, name) poly1305cls##op##_##name
-  GET  (keysz,                 "PC.keysz -> acceptable key sizes")
-  GET  (masksz,                "PC.masksz -> mask size")
-  GET  (tagsz,                 "PC.tagsz -> MAC output size")
-  GET  (name,                  "PC.name -> name of this kind of MAC")
+  GET  (keysz,         "PC.keysz -> acceptable key sizes")
+  GET  (masksz,        "PC.masksz -> mask size")
+  GET  (tagsz,         "PC.tagsz -> MAC output size")
+  GET  (name,          "PC.name -> name of this kind of MAC")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef poly1305hash_pymethods[] = {
+static const PyMethodDef poly1305hash_pymethods[] = {
 #define METHNAME(name) polymeth_##name
-  METH  (copy,                 "P.copy() -> PP")
-  METH (hash,                  "P.hash(M)")
+  NAMETH(copy,         "P.copy() -> PP")
+  METH (hash,          "P.hash(M)")
 #define METHU_(n, W, w) METH(hashu##w, "P.hashu" #w "(WORD)")
   DOUINTCONV(METHU_)
 #undef METHU_
 #define METHBUF_(n, W, w) METH(hashbuf##w, "P.hashbuf" #w "(BYTES)")
   DOUINTCONV(METHBUF_)
 #undef METHBUF_
-  METH (hashstrz,              "P.hashstrz(STRING)")
-  METH  (flush,                        "P.flush()")
-  METH  (flushzero,            "P.flushzero()")
-  METH  (concat,               "P.concat(PREFIX, SUFFIX)")
-  METH (done,                  "P.done() -> TAG")
+  METH (hashstrz,      "P.hashstrz(STRING)")
+  NAMETH(flush,                "P.flush()")
+  NAMETH(flushzero,    "P.flushzero()")
+  METH (concat,        "P.concat(PREFIX, SUFFIX)")
+  NAMETH(done,         "P.done() -> TAG")
 #undef METHNAME
   { 0 }
 };
@@ -2668,7 +2673,7 @@ static PyTypeObject poly1305cls_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Poly1305 metametaclass.  Best not to ask.",
+  "Poly1305 metametaclass.  Best not to ask.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2678,7 +2683,7 @@ static PyTypeObject poly1305cls_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  poly1305cls_pygetset,                        /* @tp_getset@ */
+  PYGETSET(poly1305cls),               /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -2716,7 +2721,7 @@ static PyTypeObject poly1305key_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"poly1305(K): Poly1305 key.",
+  "poly1305(K): Poly1305 key.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2764,7 +2769,7 @@ static PyTypeObject poly1305hash_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Poly1305 MAC context base class.",
+  "Poly1305 MAC context base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2772,7 +2777,7 @@ static PyTypeObject poly1305hash_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  poly1305hash_pymethods,              /* @tp_methods@ */
+  PYMETHODS(poly1305hash),             /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -2842,13 +2847,11 @@ end:
   return ((PyObject *)rc);
 }
 
-static PyObject *kxvikmeth_copy(PyObject *me, PyObject *arg)
+static PyObject *kxvikmeth_copy(PyObject *me)
 {
   kxvik_pyobj *k = (kxvik_pyobj *)me, *rc = 0;
-  if (!PyArg_ParseTuple(arg, ":copy")) goto end;
   rc = (kxvik_pyobj *)k->ob_type->tp_alloc(k->ob_type, 0);
   rc->s = k->s; rc->n = k->n;
-end:
   return ((PyObject *)rc);
 }
 
@@ -2897,10 +2900,9 @@ end:
   return (rc);
 }
 
-static PyObject *kxvikmeth_step(PyObject *me, PyObject *arg)
+static PyObject *kxvikmeth_step(PyObject *me)
 {
   kxvik_pyobj *k = (kxvik_pyobj *)me;
-  if (!PyArg_ParseTuple(arg, ":step")) return (0);
   keccak1600_p(&k->s, &k->s, k->n);
   RETURN_ME;
 }
@@ -2925,19 +2927,19 @@ end:
   return (rc);
 }
 
-static PyGetSetDef kxvik_pygetset[] = {
+static const PyGetSetDef kxvik_pygetset[] = {
 #define GETSETNAME(op, name) kxvik##op##_##name
-  GETSET(nround,               "KECCAK.nround -> number of rounds")
+  GETSET(nround,       "KECCAK.nround -> number of rounds")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef kxvik_pymethods[] = {
+static const PyMethodDef kxvik_pymethods[] = {
 #define METHNAME(func) kxvikmeth_##func
-  METH (copy,                  "KECCAK.copy() -> KECCAK'")
-  METH (mix,                   "KECCAK.mix(DATA)")
-  METH (extract,               "KECCAK.extract(NOCTETS)")
-  METH (step,                  "KECCAK.step()")
+  NAMETH(copy,         "KECCAK.copy() -> KECCAK'")
+  METH (mix,           "KECCAK.mix(DATA)")
+  METH (extract,       "KECCAK.extract(NOCTETS)")
+  NAMETH(step,         "KECCAK.step()")
 #undef METHNAME
   { 0 }
 };
@@ -2967,7 +2969,7 @@ static PyTypeObject kxvik_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Keccak1600([nround = 24]): Keccak-p[1600, n] state.",
+  "Keccak1600([nround = 24]): Keccak-p[1600, n] state.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -2975,9 +2977,9 @@ static PyTypeObject kxvik_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  kxvik_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(kxvik),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  kxvik_pygetset,                      /* @tp_getset@ */
+  PYGETSET(kxvik),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -3086,9 +3088,8 @@ static PyObject *shakemeth_hashstrz(PyObject *me, PyObject *arg)
   RETURN_ME;
 }
 
-static PyObject *shakemeth_xof(PyObject *me, PyObject *arg)
+static PyObject *shakemeth_xof(PyObject *me)
 {
-  if (!PyArg_ParseTuple(arg, ":xof")) goto end;
   if (shake_check(me, 0)) goto end;
   shake_xof(SHAKE_H(me));
   SHAKE_ST(me) = 1;
@@ -3110,15 +3111,13 @@ end:
   return (rc);
 }
 
-static PyObject *shakemeth_copy(PyObject *me, PyObject *arg)
+static PyObject *shakemeth_copy(PyObject *me)
 {
   shake_pyobj *rc = 0;
 
-  if (!PyArg_ParseTuple(arg, ":copy")) goto end;
   rc = PyObject_NEW(shake_pyobj, me->ob_type);
   rc->h = *SHAKE_H(me);
   rc->st = SHAKE_ST(me);
-end:
   return ((PyObject *)rc);
 }
 
@@ -3161,30 +3160,30 @@ static PyObject *shakeget_state(PyObject *me, void *hunoz)
                              st == 1 ? "squeeze" : "dead"));
 }
 
-static PyGetSetDef shake_pygetset[] = {
+static const PyGetSetDef shake_pygetset[] = {
 #define GETSETNAME(op, name) shake##op##_##name
-  GET  (rate,                  "S.rate -> rate, in bytes")
-  GET  (buffered,              "S.buffered -> amount currently buffered")
-  GET  (state,                 "S.state -> `absorb', `squeeze', `dead'")
+  GET  (rate,          "S.rate -> rate, in bytes")
+  GET  (buffered,      "S.buffered -> amount currently buffered")
+  GET  (state,         "S.state -> `absorb', `squeeze', `dead'")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef shake_pymethods[] = {
+static const PyMethodDef shake_pymethods[] = {
 #define METHNAME(func) shakemeth_##func
-  METH  (copy,                 "S.copy() -> SS")
-  METH (hash,                  "S.hash(M)")
+  NAMETH(copy,         "S.copy() -> SS")
+  METH (hash,          "S.hash(M)")
 #define METHU_(n, W, w) METH(hashu##w, "S.hashu" #w "(WORD)")
   DOUINTCONV(METHU_)
 #undef METHU_
 #define METHBUF_(n, W, w) METH(hashbuf##w, "S.hashbuf" #w "(BYTES)")
   DOUINTCONV(METHBUF_)
 #undef METHBUF_
-  METH (hashstrz,              "S.hashstrz(STRING)")
-  METH (xof,                   "S.xof()")
-  METH (done,                  "S.done(LEN) ->H")
-  METH (get,                   "S.get(LEN) -> H")
-  METH (mask,                  "S.mask(M) -> C")
+  METH (hashstrz,      "S.hashstrz(STRING)")
+  NAMETH(xof,          "S.xof()")
+  METH (done,          "S.done(LEN) -> H")
+  METH (get,           "S.get(LEN) -> H")
+  METH (mask,          "S.mask(M) -> C")
 #undef METHNAME
   { 0 }
 };
@@ -3214,7 +3213,7 @@ static PyTypeObject shake_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"SHAKE/cSHAKE base class.",
+  "SHAKE/cSHAKE/KMAC base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -3222,9 +3221,9 @@ static PyTypeObject shake_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  shake_pymethods,                     /* @tp_methods@ */
+  PYMETHODS(shake),                    /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  shake_pygetset,                      /* @tp_getset@ */
+  PYGETSET(shake),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -3262,7 +3261,7 @@ static PyTypeObject shake128_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Shake128([perso = STR], [func = STR]): SHAKE128/cSHAKE128 XOF.",
+  "Shake128([perso = STR], [func = STR]): SHAKE128/cSHAKE128 XOF.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -3310,7 +3309,7 @@ static PyTypeObject shake256_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Shake256([perso = STR], [func = STR]): SHAKE256/cSHAKE256 XOF.",
+  "Shake256([perso = STR], [func = STR]): SHAKE256/cSHAKE256 XOF.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -3465,19 +3464,19 @@ end:
   return (rc);
 }
 
-static PyGetSetDef gcprp_pygetset[] = {
+static const PyGetSetDef gcprp_pygetset[] = {
 #define GETSETNAME(op, name) gcp##op##_##name
-  GET  (keysz,                 "CP.keysz -> acceptable key sizes")
-  GET  (blksz,                 "CP.blksz -> block size")
-  GET  (name,                  "CP.name -> name of this kind of PRP")
+  GET  (keysz,         "CP.keysz -> acceptable key sizes")
+  GET  (blksz,         "CP.blksz -> block size")
+  GET  (name,          "CP.name -> name of this kind of PRP")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef gprp_pymethods[] = {
+static const PyMethodDef gprp_pymethods[] = {
 #define METHNAME(name) gpmeth_##name
-  METH (encrypt,               "P.encrypt(PT) -> CT")
-  METH (decrypt,               "P.decrypt(CT) -> PT")
+  METH (encrypt,       "P.encrypt(PT) -> CT")
+  METH (decrypt,       "P.decrypt(CT) -> PT")
 #undef METHNAME
   { 0 }
 };
@@ -3507,7 +3506,7 @@ static PyTypeObject gcprp_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Pseudorandom permutation metaclass.",
+  "Pseudorandom permutation metaclass.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -3517,7 +3516,7 @@ static PyTypeObject gcprp_pytype_skel = {
   0,                                   /* @tp_iternext@ */
   0,                                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  gcprp_pygetset,                      /* @tp_getset@ */
+  PYGETSET(gcprp),                     /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -3555,7 +3554,7 @@ static PyTypeObject gprp_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Pseudorandom permutation, abstract base class.",
+  "Pseudorandom permutation, abstract base class.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -3563,7 +3562,7 @@ static PyTypeObject gprp_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  gprp_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(gprp),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
@@ -3580,28 +3579,10 @@ static PyTypeObject gprp_pytype_skel = {
 
 /*----- Main code ---------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
-  METH (_KeySZ_fromdl,         "\
-fromdl(N) -> M: convert integer discrete log field size to work factor")
-  METH (_KeySZ_fromschnorr,    "\
-fromschnorr(N) -> M: convert Schnorr group order to work factor")
-  METH (_KeySZ_fromif,         "\
-fromif(N) -> M: convert integer factorization problem size to work factor")
-  METH (_KeySZ_fromec,         "\
-fromec(N) -> M: convert elliptic curve group order to work factor")
-  METH (_KeySZ_todl,           "\
-todl(N) -> M: convert work factor to integer discrete log field size")
-  METH (_KeySZ_toschnorr,      "\
-toschnorr(N) -> M: convert work factor to Schnorr group order")
-  METH (_KeySZ_toif,           "\
-toif(N) -> M: convert work factor to integer factorization problem size")
-  METH (_KeySZ_toec,           "\
-toec(N) -> M: convert work factor to elliptic curve group order")
-  METH (_KeySZ_toec,           "\
-toec(N) -> M: convert work factor to elliptic curve group order")
-#define METH_HDANCE(hdance, HDance) METH(hdance##_prf, "\
-" #hdance "_prf(K, N) -> H: calculate " HDance " hash of N with K")
+#define METH_HDANCE(hdance, HDance) METH(hdance##_prf,                 \
+        "" #hdance "_prf(K, N) -> H: calculate " HDance " hash of N with K")
   METH_HDANCE(hsalsa20, "HSalsa20")
   METH_HDANCE(hsalsa2012, "HSalsa20/12")
   METH_HDANCE(hsalsa208, "HSalsa20/8")