Add internal size and seed size of hash algo

This commit is contained in:
Christian Heimes 2013-10-03 15:15:51 +02:00
parent afc47ea51a
commit 0071641f77
1 changed files with 13 additions and 7 deletions

View File

@ -312,7 +312,7 @@ hash function
function prototype:: 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 hash function table
@ -321,9 +321,11 @@ hash function table
type definition:: type definition::
typedef struct { typedef struct {
PyHash_func_t hashfunc; PyHash_Func hashfunc; /* function pointer */
char *name; char *name; /* name of the hash algorithm and variant */
unsigned int precedence; int hash_bits; /* internal size of hash value */
int seed_bits; /* size of seed input */
int precedence; /* ranking for auto-selection */
} PyHash_FuncDef; } PyHash_FuncDef;
PyAPI_DATA(PyHash_FuncDef *) PyHash_FuncTable; PyAPI_DATA(PyHash_FuncDef *) PyHash_FuncTable;
@ -331,9 +333,9 @@ type definition::
Implementation:: Implementation::
PyHash_FuncDef hash_func_table[] = { PyHash_FuncDef hash_func_table[] = {
{fnv, "fnv", 10}, {fnv, "fnv", 64, 128, 10},
#ifdef PY_UINT64_T #ifdef PY_UINT64_T
{siphash24, "sip24", 20}, {siphash24, "sip24", sizeof(Py_hash_t)*8, sizeof(Py_hash_t)*8, 20},
#endif #endif
{NULL, NULL}, {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 _testcapi