PyObject#

class einspect.structs.py_object.PyObject(__obj: Union[_T, PyObject[_T, _KT, _VT]])#
class einspect.structs.py_object.PyObject(*, ob_refcnt: int = 1, ob_type: LP_PyTypeObject, **kwargs)

Defines a base PyObject Structure.

DelAttr(name)#

Delete attribute name of the PyObject. Returns -1 on failure.

Return type:

int

as_gc()#

Return the PyGC_Head struct of this object.

Return type:

PyGC_Head

as_ref()#

Return a pointer to the Structure.

Return type:

<object object at 0x7fd11384d530>

astype(dtype)#

Cast the PyObject into another PyObject type.

Return type:

TypeVar(_ST, bound= Structure)

classmethod from_gc(gc)#

Create a PyObject from a PyGC_Head struct.

Return type:

Self

classmethod from_object(obj)#

Create a PyObject from an object.

Return type:

Self

gc_is_tracked()#

Return True if the PyObject is currently tracked by the GC.

Return type:

bool

gc_may_be_tracked()#

Return True if the PyObject may be tracked by the GC in the future, or already is.

https://github.com/python/cpython/blob/3.11/Include/internal/pycore_gc.h#L28-L32

Return type:

bool

instance_dict()#

Return the instance dict of the PyObject.

An offset override can be set by __st_dictoffset__. It should be relative to the address of the PyObject.

https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_dictoffset

Return type:

Optional[LP_PyObject]

into_object()#

Cast the PyObject into a Python object.

Return type:

TypeVar(_T)

is_gc()#

Returns True if the object implements the GC protocol.

The object cannot be tracked by the garbage collector if False.

https://github.com/python/cpython/blob/3.11/Include/internal/pycore_object.h#L209-L216

Return type:

bool

classmethod try_from(obj_or_ptr)#

Create a PyObject from a PyObject, pointer to a PyObject, or object.

Return type:

Self

with_ref(n=1)#

Increment the reference count of the PyObject by n. Return self.

Return type:

Self

property address: int#

Return the address of the PyObject.

property mem_size: int#

Return the size of the PyObject in memory.

PyVarObject#

class einspect.structs.py_object.PyVarObject(__obj: Union[_T, PyObject[_T, _KT, _VT]])#
class einspect.structs.py_object.PyVarObject(*, ob_refcnt: int = 1, ob_type: LP_PyTypeObject, **kwargs)

Defines a base PyVarObject Structure.

https://github.com/python/cpython/blob/3.11/Include/object.h#L109-L112

DelAttr(name)#

Delete attribute name of the PyObject. Returns -1 on failure.

Return type:

int

as_gc()#

Return the PyGC_Head struct of this object.

Return type:

PyGC_Head

as_ref()#

Return a pointer to the Structure.

Return type:

<object object at 0x7fd11384d530>

astype(dtype)#

Cast the PyObject into another PyObject type.

Return type:

TypeVar(_ST, bound= Structure)

classmethod from_gc(gc)#

Create a PyObject from a PyGC_Head struct.

Return type:

Self

classmethod from_object(obj)#

Create a PyObject from an object.

Return type:

Self

gc_is_tracked()#

Return True if the PyObject is currently tracked by the GC.

Return type:

bool

gc_may_be_tracked()#

Return True if the PyObject may be tracked by the GC in the future, or already is.

https://github.com/python/cpython/blob/3.11/Include/internal/pycore_gc.h#L28-L32

Return type:

bool

instance_dict()#

Return the instance dict of the PyObject.

An offset override can be set by __st_dictoffset__. It should be relative to the address of the PyObject.

https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_dictoffset

Return type:

Optional[LP_PyObject]

into_object()#

Cast the PyObject into a Python object.

Return type:

TypeVar(_T)

is_gc()#

Returns True if the object implements the GC protocol.

The object cannot be tracked by the garbage collector if False.

https://github.com/python/cpython/blob/3.11/Include/internal/pycore_object.h#L209-L216

Return type:

bool

classmethod try_from(obj_or_ptr)#

Create a PyObject from a PyObject, pointer to a PyObject, or object.

Return type:

Self

with_ref(n=1)#

Increment the reference count of the PyObject by n. Return self.

Return type:

Self

property address: int#

Return the address of the PyObject.

property mem_size: int#

Return the size of the PyObject in memory.