What is a PyObject in Python? What is a PyObject in Python? python python

What is a PyObject in Python?


Every value you can touch in Python is a PyObject in C. That includes lists, dictionaries, sockets, files, integers, strings, functions, classes, you name it. If you can touch it in Python, it’s a PyObject in C.


A PyObject is in fact just a Python object at the C level. And since integers in Python are objects, they are also PyObjects. It doesn't matter whether it was written in Python or in C, it is a PyObject at the C level regardless.