v4: improve memory management tooling
Open
@ajfriend is already working on this.
Since May 25, 2022.
v4
- Dominant language
- Python
- Stars
- 1k
- Forks
- 144
- Avg merge
- 7d 14h
- Merged PRs (30d)
- 2
Description
I'd like a better Cython primitive for allocating, filling, and converting from an H3 index array to a Cython memview than our current approach of paired function calls to create_ptr and create_mv.
Example:
cpdef H3int[:] get_pentagon_indexes(int res):
cdef:
h3lib.H3Error err
check_res(res)
n = h3lib.pentagonCount()
ptr = create_ptr(n)
err = h3lib.getPentagons(res, ptr)
mv = create_mv(ptr, n)
return mv
Ideas:
- context manager (i'm not sure this can be done ergonomically)
- "memory manager" object that's in control of the size, allocation, type, and memory-view-creation of the memory
- avoid the need to mentally pair the memory and the memory size
- can have accessor methods or Python attributes to create/access the pointer and memory view
Other kinds of arrays
This pattern also doesn't cover when we have to allocate space for non-H3Index arrays.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.