Skip to content

Commit 03acd4b

Browse files
committed
Introduce a property to get the pointer to the underlying bitmap
This is useful for FFI.
1 parent 6a6f5dd commit 03acd4b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

pyroaring/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class AbstractBitMap:
3232
def __init__(self, values: Iterable[int] | None = None, copy_on_write: bool = False, optimize: bool = True) -> None:
3333
...
3434

35+
@property
36+
def ptr(self) -> int:
37+
...
38+
3539
@property
3640
def copy_on_write(self) -> bool:
3741
...

pyroaring/abstract_bitmap.pxi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cimport croaring
2-
from libc.stdint cimport uint32_t, uint64_t, int64_t
2+
from libc.stdint cimport uint32_t, uint64_t, uintptr_t, int64_t
33
from libcpp cimport bool
44
from libcpp.vector cimport vector
55
from libc.stdlib cimport free, malloc
@@ -174,6 +174,13 @@ cdef class AbstractBitMap:
174174
(<AbstractBitMap>bm)._c_bitmap = ptr
175175
return bm
176176

177+
@property
178+
def ptr(self):
179+
"""
180+
The pointer to the underlying CRoaring bitmap as an integer.
181+
"""
182+
return <uintptr_t>self._c_bitmap
183+
177184
@property
178185
def copy_on_write(self):
179186
"""

0 commit comments

Comments
 (0)