In Python everything is an object. Also every object has a type. In fact the type of an object is also an object and therefore must also have its own type. Types have a special type that is called type
. This (like any other type) is an object and is therefore an instance of object
.
Every object is an instance of object
including any type of any object. So int
is an object and so is str
as well as more obvious examples such as 1
and 'asd'
. Anything that you can refer to or assign to a variable in Python is an instance of object
.
Since object
is a type it is an instance of type
. This means that object
and type
are both instances of each other. This is not "inheritance" regardless of what the other answer you linked says. The relationship is the same as the relationship between int
and 1
: the object resulting from 1
is an instance of int
. The quirk here is that object
and type
are both instances of each other.
From a Python perspective these two mean different things. The object
type has an ontological role: everything is an object (and nothing else exists). So to say that type
is an object just means that it exists as far as Python's model is concerned. On the other hand object
is the base type of all objects so it is a type. As a type it must be an instance of type
which like any other object is an instance of object
.
As far as the interpreters are implemented: the fact that type
is an instance of object
is convenient since it maintains "everything is an object" which is useful for e.g. deallocating objects at shutdown. The fact that object
is an instance of type
is useful since it makes it straight-forward to ensure that it behaves like other type objects.