Skip to content

Commit 01f2be1

Browse files
vyasrleofang
andauthored
Improve documentation of CUstream.getPtr (#765)
* Update doc * nit: fix rendering --------- Co-authored-by: Leo Fang <leo80042@gmail.com>
1 parent b827181 commit 01f2be1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cuda_bindings/docs/source/tips_and_tricks.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Getting the address of underlying C objects from the low-level bindings
99

1010
All CUDA C types are exposed to Python as Python classes. For example, the :class:`~cuda.bindings.driver.CUstream` type is exposed as a class with methods :meth:`~cuda.bindings.driver.CUstream.getPtr()` and :meth:`~cuda.bindings.driver.CUstream.__int__()` implemented.
1111

12-
There is an important distinction between the ``getPtr()`` method and the behaviour of ``__int__()``. If you need to get the pointer address *of* the underlying ``CUstream`` C object wrapped in the Python class, you can do so by calling ``int(instance_of_CUstream)``, which returns the address as a Python `int`, while calling ``instance_of_CUstream.getPtr()`` returns the pointer *to* the ``CUstream`` C object (that is, ``&CUstream``) as a Python `int`.
12+
There is an important distinction between the ``getPtr()`` method and the behaviour of ``__int__()``. Since a ``CUstream`` is itself just a pointer, calling ``instance_of_CUstream.getPtr()`` returns the pointer *to* the pointer, instead of the value of the ``CUstream`` C object that is the pointer to the underlying stream handle. ``int(instance_of_CUstream)`` returns the value of the ``CUstream`` converted to a Python int and is the actual address of the underlying handle.
1313

1414

1515
Lifetime management of the CUDA objects

0 commit comments

Comments
 (0)