Hashing in python

Paul Rubin no.email at nospam.invalid
Sun Feb 14 04:56:03 CET 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