The short answer is "yes."
The reference implementation of Python is CPython which is, as its name suggests, written in C. And yes, everything is an object (even integers and Booleans). In fact, the values True
and False
are singletons. Integer values are just objects too (the numbers -5 through, IIRC, 255 or so are singletons as well).
All Python objects consist of, at a minimum, a reference count, type metadata, and support for a doubly linked list of all objects on the heap:
struct _object {
_PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt;
PyTypeObject *ob_type;
};
_PyObject_HEAD_EXTRA
is a macro used to support a doubly linked list of all heap objects. ob_refcnt
is the reference count. *ob_type
is type information.