PyTypeObject#

class einspect.structs.py_type.PyTypeObject(*args, **kwargs)#

Defines a PyTypeObject Structure.

https://github.com/python/cpython/blob/3.11/Doc/includes/typestruct.h

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)

delattr_safe(name)#

Delete an attribute on the type object. Uses custom overrides if available.

Return type:

None

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:

PyTypeObject[Type[TypeVar(_T)]]

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()#

Return True if the type has GC support.

https://docs.python.org/3/c-api/type.html#c.PyType_IS_GC https://github.com/python/cpython/blob/3.11/Include/objimpl.h#L160-L161

Return type:

bool

setattr_safe(name, value)#

Set an attribute on the type object. Uses custom overrides if available.

Return type:

None

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.