Skip to content

Commit 492cc20

Browse files
authored
perf: remove warnings calls in smv constructor methods (#1431)
1 parent 66c4f2c commit 492cc20

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

cuda_core/cuda/core/_memoryview.pyx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,19 @@ cdef class StridedMemoryView:
137137

138138
@classmethod
139139
def from_dlpack(cls, obj: object, stream_ptr: int | None=None) -> StridedMemoryView:
140-
cdef StridedMemoryView buf
141-
with warnings.catch_warnings():
142-
# ignore the warning triggered by calling the constructor
143-
# inside the library we're allowed to do this
144-
warnings.simplefilter("ignore", DeprecationWarning)
145-
buf = cls()
140+
cdef StridedMemoryView buf = StridedMemoryView.__new__(cls)
146141
view_as_dlpack(obj, stream_ptr, buf)
147142
return buf
148143

149144
@classmethod
150145
def from_cuda_array_interface(cls, obj: object, stream_ptr: int | None=None) -> StridedMemoryView:
151-
cdef StridedMemoryView buf
152-
with warnings.catch_warnings():
153-
warnings.simplefilter("ignore", DeprecationWarning)
154-
buf = cls()
146+
cdef StridedMemoryView buf = StridedMemoryView.__new__(cls)
155147
view_as_cai(obj, stream_ptr, buf)
156148
return buf
157149

158150
@classmethod
159151
def from_array_interface(cls, obj: object) -> StridedMemoryView:
160-
cdef StridedMemoryView buf
161-
with warnings.catch_warnings():
162-
warnings.simplefilter("ignore", DeprecationWarning)
163-
buf = cls()
152+
cdef StridedMemoryView buf = StridedMemoryView.__new__(cls)
164153
view_as_array_interface(obj, buf)
165154
return buf
166155

0 commit comments

Comments
 (0)