Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python/tvm_ffi/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class Object:
def __ne__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __init_handle_by_constructor__(self, fconstructor: Function, *args: Any) -> None: ...
def __ffi_init__(self, *args: Any) -> None:
"""Initialize the instance using the ` __init__` method registered on C++ side.

Parameters
----------
args: list of objects
The arguments to the constructor
Comment on lines +49 to +54
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Same docstring issues as implementation: backticked name contains an extra space ( __init__) and parameter description should reflect variadic positional arguments rather than 'list of objects'. Mirror the corrected wording in the implementation for consistency.

Suggested change
"""Initialize the instance using the ` __init__` method registered on C++ side.
Parameters
----------
args: list of objects
The arguments to the constructor
"""Initialize the instance using the `__init__` method registered on the C++ side.
Parameters
----------
args
Positional arguments to pass to the constructor.

Copilot uses AI. Check for mistakes.

"""
def same_as(self, other: Any) -> bool: ...
def _move(self) -> ObjectRValueRef: ...
def __move_handle_from__(self, other: Object) -> None: ...
Expand Down Expand Up @@ -240,6 +249,7 @@ class TypeField:
frozen: bool
getter: Any
setter: Any
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] New attribute dataclass_field is added without any doc/comment explaining its purpose or when it may be None. Consider adding a brief class-level note or inline comment to clarify its role (e.g., link to dataclass reflection mechanism) to aid future maintainability.

Suggested change
setter: Any
setter: Any
# Reference to the corresponding dataclass field, if the FFI-backed type is also a Python dataclass.
# May be None if no dataclass field is associated (e.g., for non-dataclass types).

Copilot uses AI. Check for mistakes.
dataclass_field: Any | None

def as_property(self, cls: type) -> property: ...

Expand Down
10 changes: 10 additions & 0 deletions python/tvm_ffi/cython/object.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ cdef class Object:
(<Object>fconstructor).chandle, <PyObject*>args, &chandle, NULL)
self.chandle = chandle

def __ffi_init__(self, *args) -> None:
"""Initialize the instance using the `__init__` method registered on the C++ side.

Parameters
----------
args : Any
Positional arguments forwarded to the registered C++ __init__.
"""
self.__init_handle_by_constructor__(type(self)._C___init__, *args)

def same_as(self, other):
"""Check object identity.

Expand Down
Loading