Skip to content

Commit

Permalink
Fix: Portable way of matching 32-bit builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Jul 30, 2023
1 parent 3500812 commit 604e634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions include/usearch/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
#endif

// Inferring hardware bitness: 32 vs 64
#if __WORDSIZE == 64
// https://stackoverflow.com/a/5273354
#if INTPTR_MAX == INT64_MAX
#define USEARCH_64BIT_ENV
#else
#elif INTPTR_MAX == INT32_MAX
#define USEARCH_32BIT_ENV
#else
#error Unknown pointer size or missing size macros!
#endif

#if !defined(USEARCH_USE_OPENMP)
Expand Down
10 changes: 6 additions & 4 deletions python/usearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,16 @@ def __init__(
self._compiled.load(path)

@staticmethod
def metadata(path: os.PathLike) -> dict:
def metadata(path: os.PathLike) -> Optional[dict]:
if not os.path.exists(path):
return None
return index_metadata(path)

@staticmethod
def restore(path: os.PathLike, view: bool = False) -> Index:
if not os.path.exists(path):
return None
def restore(path: os.PathLike, view: bool = False) -> Optional[Index]:
meta = Index.metadata(path)
if not meta:
return None
return Index(
ndim=meta["dimensions"],
dtype=meta["kind_scalar"],
Expand Down

0 comments on commit 604e634

Please sign in to comment.