[Python-Dev] Hashing proposal: change only string-only dicts (original) (raw)
PJ Eby pje at telecommunity.com
Wed Jan 18 17:01:10 CET 2012
- Previous message: [Python-Dev] Hashing proposal: change only string-only dicts
- Next message: [Python-Dev] Hashing proposal: change only string-only dicts
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jan 17, 2012 at 7:58 PM, "Martin v. Löwis" <martin at v.loewis.de>wrote:
Am 17.01.2012 22:26, schrieb Antoine Pitrou: > Only 2 bits are used in obsstate, meaning 30 are left. These 30 bits > could cache a "hash perturbation" computed from the string and the > random bits: > > - hash() would use obshash > - dictlookup() would use ((obshash * 1000003) ^ (obsstate & ~3)) > > This way, you cache almost all computations, adding only a computation > and a couple logical ops when looking up a string in a dict.
That's a good idea. For Unicode, it might be best to add another slot into the object, even though this increases the object size.
Wouldn't that break the ABI in 2.x? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120118/6abf94a1/attachment.html>
- Previous message: [Python-Dev] Hashing proposal: change only string-only dicts
- Next message: [Python-Dev] Hashing proposal: change only string-only dicts
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]