Hashing in python

Paul Rubin no.email at nospam.invalid
Sat Feb 13 22:56:03 EST 2010


Vish <vahuja4 at gmail.com> writes:
> I need to hash 3d coordinates to a grid which has been divided into
> 4*4*4 squares. Using python, I thought of a simple way as follows:

Use the built-in hash function:

    >>> p = (1, 2, 3)
    >>> print hash(p)
    2528502973977326415

You can of course mod that by the table size:

    >>> print hash(p) % (4*4*4)
    15



More information about the Python-list mailing list