Skip to content

Commit

Permalink
more robust repr handling
Browse files Browse the repository at this point in the history
  • Loading branch information
leofang committed Sep 6, 2024
1 parent 48a305c commit 94ec937
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cuda_py/cuda/py/_memoryview.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ cdef class GPUMemoryView:
return (f"GPUMemoryView(ptr={self.ptr},\n"
+ f" shape={self.shape},\n"
+ f" strides={self.strides},\n"
+ f" dtype={self.dtype.__name__},\n"
+ f" dtype={get_simple_repr(self.dtype)},\n"
+ f" device_id={self.device_id},\n"
+ f" device_accessible={self.device_accessible},\n"
+ f" readonly={self.readonly},\n"
+ f" obj={get_simple_repr(self.obj)})")


cdef str get_simple_repr(obj):
cdef object obj_class = obj.__class__
cdef object obj_class
cdef str obj_repr
if isinstance(obj, type):
obj_class = obj
else:
obj_class = obj.__class__
if obj_class.__module__ in (None, "builtins"):
obj_repr = obj_class.__name__
else:
Expand Down

0 comments on commit 94ec937

Please sign in to comment.