Previous topic

music21.figuredBass.examples

Next topic

music21.figuredBass.notation

Table Of Contents

Table Of Contents

music21.figuredBass.fbPitch

HashablePitch

Inherits from: Pitch, Music21Object, JSONSerializer

class music21.figuredBass.fbPitch.HashablePitch(name=None, **keywords)

A HashablePitch takes on identical properties as a Pitch. It only defines a hash function, such that two identical HashablePitch instances hash to the same thing. This is not the case for two identical Pitch instances.

Internally, fbRealizer uses HashablePitch instances in place of Pitch instances, to allow possibilities (see possibility) to be used as dictionary keys for movements between Segment instances.

>>> from music21.figuredBass import fbPitch
>>> from music21 import pitch
>>> h1 = fbPitch.HashablePitch('G4')
>>> p1 = pitch.Pitch('G4')
>>> h1 == p1
True
>>> h2 = fbPitch.HashablePitch('G4')
>>> p2 = pitch.Pitch('G4')
>>> hash(h1) == hash(h2)
True
>>> hash(p1) == hash(p2)
False