diff --git a/cuda_core/cuda/core/_event.pyx b/cuda_core/cuda/core/_event.pyx index 0d25959a22..ec9f41c004 100644 --- a/cuda_core/cuda/core/_event.pyx +++ b/cuda_core/cuda/core/_event.pyx @@ -172,7 +172,7 @@ cdef class Event: raise RuntimeError(explanation) def __hash__(self) -> int: - return hash((type(self), as_intptr(self._h_context), as_intptr(self._h_event))) + return hash((type(self), as_intptr(self._h_event))) def __eq__(self, other) -> bool: # Note: using isinstance because `Event` can be subclassed. diff --git a/cuda_core/cuda/core/_stream.pyx b/cuda_core/cuda/core/_stream.pyx index 05cbcce76a..2b5cdfabd2 100644 --- a/cuda_core/cuda/core/_stream.pyx +++ b/cuda_core/cuda/core/_stream.pyx @@ -217,22 +217,12 @@ cdef class Stream: return (0, as_intptr(self._h_stream)) def __hash__(self) -> int: - # Ensure context is initialized for hash consistency - Stream_ensure_ctx(self) - return hash((as_intptr(self._h_context), as_intptr(self._h_stream))) + return hash(as_intptr(self._h_stream)) def __eq__(self, other) -> bool: if not isinstance(other, Stream): return NotImplemented - cdef Stream _other = other - # Fast path: compare handles first - if as_intptr(self._h_stream) != as_intptr(_other._h_stream): - return False - # Ensure contexts are initialized for both streams - Stream_ensure_ctx(self) - Stream_ensure_ctx(_other) - # Compare contexts as well - return as_intptr(self._h_context) == as_intptr(_other._h_context) + return as_intptr(self._h_stream) == as_intptr((other)._h_stream) @property def handle(self) -> cuda.bindings.driver.CUstream: