Example:
|
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))) |
@stiepan reported offline that this is problematic because at least for streams we do not always know the CUDA context associated with them (we could be wrapping a foreign stream), and triggering a lookup is expensive. Some of the objects are even independent of CUDA contexts.
We decided to follow cccl-rt and do a simple pointer comparison for __eq__. We should stick to this principle for __hash__ as well.
Example:
cuda-python/cuda_core/cuda/core/_stream.pyx
Lines 183 to 186 in 39e3293
@stiepan reported offline that this is problematic because at least for streams we do not always know the CUDA context associated with them (we could be wrapping a foreign stream), and triggering a lookup is expensive. Some of the objects are even independent of CUDA contexts.
We decided to follow cccl-rt and do a simple pointer comparison for
__eq__. We should stick to this principle for__hash__as well.