You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
from_handle constructors need to allow managing ownership #1187
Currently all objects in cuda.core have a from_handle constructor (#192), allowing constructing the object from an underlying C handle allocated elsewhere. However, currently this gives a view-only semantics, and could not help manage the handle lifetime. It'd be nice to have a kw(-only) argument added that allows optionally handling the lifetime, or even acquiring the ownership.
changed the title [-]`from_handle` constructor needs to allow managing ownership[/-][+]`from_handle` constructors need to allow managing ownership[/+]on Oct 24, 2025
A comment on UX. For quite some time, I was convinced there's no way to tie the lifetime of external stream instance to cuda.core's Stream. Reading Stream documentation falsely reassured me in that - the from_handle only accepts a raw ptr. Turns out you can do this: pass to Device.create_stream an object that implements __cuda_stream__ protocol (so oftentimes a custom wrapper), but I've learnt that accidentaly after quite some time of working with cuda.core.
Activity
[-]`from_handle` constructor needs to allow managing ownership[/-][+]`from_handle` constructors need to allow managing ownership[/+]stiepan commentedon Mar 10, 2026
A comment on UX. For quite some time, I was convinced there's no way to tie the lifetime of external stream instance to cuda.core's Stream. Reading Stream documentation falsely reassured me in that - the from_handle only accepts a raw ptr. Turns out you can do this: pass to
Device.create_streaman object that implements__cuda_stream__protocol (so oftentimes a custom wrapper), but I've learnt that accidentaly after quite some time of working with cuda.core.