Choose the right H3 API based on performance and convenience
masterThe h3-py library provides several APIs that share the same functions but differ in how they represent H3 indices and collections. Choosing the right API allows you to balance Pythonic convenience with computational speed.
API Comparison Summary
| API | Index Type | Collection Type | Best For |
|---|---|---|---|
h3.api.basic_str (Default) | Python str (hexadecimal) | list, set | Human readability and standard Python workflows. |
h3.api.basic_int | Python int | list, set | Integer-based math without string conversion overhead. |
h3.api.numpy_int | numpy.uint64 | numpy.ndarray | High-performance, memory-efficient bulk computations. |
h3.api.memview_int | uint64 | memoryview | High performance without requiring a numpy dependency. |
Conversion Pattern
A common high-performance pattern is to perform heavy computations using h3.api.numpy_int or h3.api.memview_int, and then convert the final results to strings for reporting or inspection using h3.int_to_str().