pg.hash

Accessible via pg.hash, pg.symbolic.hash.

hash(x)[source]

Returns hash of value. Use symbolic hashing function if possible.

Example:

@pg.symbolize
class A:
  def __init__(self, x):
    self.x = x

assert hash(A(1)) != hash(A(1))
assert pg.hash(A(1)) == pg.hash(A(1))
assert pg.hash(pg.Dict(x=[A(1)])) == pg.hash(pg.Dict(x=[A(1)]))
Return type:

int

Parameters:

x – Value for computing hash.

Returns:

The hash value for x.