From 0071641f7731b3d6711f559283f821d26932310d Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 3 Oct 2013 15:15:51 +0200 Subject: [PATCH] Add internal size and seed size of hash algo --- pep-0456.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pep-0456.txt b/pep-0456.txt index abf2e21ce..24b5d4f71 100644 --- a/pep-0456.txt +++ b/pep-0456.txt @@ -312,7 +312,7 @@ hash function function prototype:: - typedef Py_hash_t (*PyHash_func_t)(void *, Py_ssize_t); + typedef Py_hash_t (*PyHash_Func)(const void *, Py_ssize_t); hash function table @@ -321,9 +321,11 @@ hash function table type definition:: typedef struct { - PyHash_func_t hashfunc; - char *name; - unsigned int precedence; + PyHash_Func hashfunc; /* function pointer */ + char *name; /* name of the hash algorithm and variant */ + int hash_bits; /* internal size of hash value */ + int seed_bits; /* size of seed input */ + int precedence; /* ranking for auto-selection */ } PyHash_FuncDef; PyAPI_DATA(PyHash_FuncDef *) PyHash_FuncTable; @@ -331,9 +333,9 @@ type definition:: Implementation:: PyHash_FuncDef hash_func_table[] = { - {fnv, "fnv", 10}, + {fnv, "fnv", 64, 128, 10}, #ifdef PY_UINT64_T - {siphash24, "sip24", 20}, + {siphash24, "sip24", sizeof(Py_hash_t)*8, sizeof(Py_hash_t)*8, 20}, #endif {NULL, NULL}, }; @@ -376,7 +378,11 @@ algorithm as well as all available algorithms. :: - sys.hash_info(algorithm='siphash24', available=('siphash24', 'fnv')) + sys.hash_info(algorithm='siphash24', + available_algorithms=('siphash24', 'fnv'), + hash_bits=64, + hash_output=64, # sizeof(Py_hash_t)*8 + seed_bits=128) _testcapi