Message103843
> Regarding a hash function for complex types, I think documenting the
> existing behavior for PyComplex is sufficient. The magic number 1000003 > could be documented in hash_info as 'multiplier' and _PyHASH_MULTIPLIER.
Seems reasonable; I'm tempted to call the constant it hash_info.imaginary and _PyHASH_IMAGINARY, though. :)
There's also an implicit parameter in this algorithm, namely the size of a C long; I think this should go into sys.hash_info, too.
complex_hash does need fixing in one respect: it currently depends on signed overflow wrapping modulo 2**BIT_IN_LONG, but that's undefined behaviour; it should use unsigned arithmetic instead.
> I think hash(m/P) should preserve sign. It just seems more symmetrical. :)
Agreed. Along similar lines, I think I'm also going to get rid of _PyHASH_NINF and just use -PyHASH_INF instead. |
|
Date |
User |
Action |
Args |
2010-04-21 13:47:38 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, Rhamphoryncus, casevh, eric.smith, skrah |
2010-04-21 13:47:38 | mark.dickinson | set | messageid: <1271857658.31.0.217589954276.issue8188@psf.upfronthosting.co.za> |
2010-04-21 13:47:35 | mark.dickinson | link | issue8188 messages |
2010-04-21 13:47:35 | mark.dickinson | create | |
|