[Python-checkins] peps: Add internal size and seed size of hash algo
christian.heimes
python-checkins at python.org
Thu Oct 3 15:15:59 CEST 2013
http://hg.python.org/peps/rev/cc863d6be5b2
changeset: 5161:cc863d6be5b2
user: Christian Heimes <christian at cheimes.de>
date: Thu Oct 03 15:15:51 2013 +0200
summary:
Add internal size and seed size of hash algo
files:
pep-0456.txt | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/pep-0456.txt b/pep-0456.txt
--- a/pep-0456.txt
+++ b/pep-0456.txt
@@ -312,7 +312,7 @@
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 @@
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 @@
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 @@
::
- 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
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list