In the first place Git is a key-value storage system. The keys are called OIDs, for Object ID, and the values stored are called Objects.
The oid is the SHA-1 hash of an object. It is 20 bytes long.
These are the three forms of an oid in pygit2:
A hex oid is represented as a Python string of 40 hexadecimal chars. This form can be used to create Oid objects, just like raw oids. Also, the pygit2 API directly accepts hex oids everywhere.
Note
In Python 3 hexadecimal oids are represented using the str type. In Python 2 both str and unicode are accepted.
An Oid object can be built from the raw or hexadecimal representations (see below). The pygit2 API always returns, and accepts, Oid objects.
This is the preferred way to represent an Oid, with the hexadecimal form being used for interaction with the user.
And the other way around, from an Oid object we can get the hexadecimal and raw forms. You can use the built-in str() (or unicode() in python 2) to get the hexadecimal representation of the Oid.
The Oid type supports: