uber / uber/h3-py

v4: improve memory management tooling

Open
#249 1 comment 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.