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
- 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:
- 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_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:
- 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
]
- 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:
- setattr_safe(name, value)#
Set an attribute on the type object. Uses custom overrides if available.
- Return type:
- 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