python NGT
Install
Python binding with pybind11 (ngtpy) is installed as follows.
pip3 install ngt
You can install the python bindings from source code. You MUST install the NGT library according to the README before installing the python bindings as follows.
cd NGT_ROOT/python
pip3 install .
Please note that the search speed of the ngtpy packages from PyPI is slower than that of the ngtpy that is built on your computer so that the package can be run on older CPUs.
Documents
Simple samples
ngtpy (pybind11)
ngtpy(pybind11) can reduce the processing times than ngt(ctypes). It is more effective especially for the short search time.
import ngtpy
import random
dim = 10
nb = 100
vectors = [[random.random() for _ in range(dim)] for _ in range(nb)]
query = vectors[0]
ngtpy.create(b"tmp", dim)
index = ngtpy.Index(b"tmp")
index.batch_insert(vectors)
index.save()
results = index.search(query, 3)
for i, (id, distance) in enumerate(results) :
print(str(i) + ": " + str(id) + ", " + str(distance))
object = index.get_object(id)
print(object)
See also sample.py.
Release files for ngt 2.8.0.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 126.0 MB
Release files / ngt-2.8.0.post1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | ngt-2.8.0.post1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
f1598cc2535e87eb46c4dc2b6339828e566cfb16713f6113af7eb0ff4c32245e
|
|
BLAKE2b-256 checksum How to use checksums |
11a054ce66126f0833e7280997fcd03373f4b42b12d2983bc0a841b1d548c16c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ngt-2.8.0.post1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | ngt-2.8.0.post1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 11.6 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
9d93298e45aeaa8acab4f0fce83cae69e2d754cce3d8e931e4ce2ae454f5d747
|
|
BLAKE2b-256 checksum How to use checksums |
f0633080bdfc85895aba2fd01cb4fcb471c1887c148b7ee22dece49eaeb8706a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | ngt-2.8.0.post1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
16288e7591e83051b7e0de25a30eb605854ec327c1a7a9df7745af03ecbedfb6
|
|
BLAKE2b-256 checksum How to use checksums |
ae8127f13a3a16bbb41db69b916867beac22a5797e1aa3ad6b8ef186dc6e2ede
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ngt-2.8.0.post1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | ngt-2.8.0.post1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 11.5 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
312ed0e1ff834a894fdd5bc431f5e2c387c16b9a23b5c29c803d69618f9b7426
|
|
BLAKE2b-256 checksum How to use checksums |
1a3760d80c9c24d7bc462fe994135c0e48d4f18ebd0abeebdf7fd37a058d22f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp314-cp314-macosx_26_0_arm64.whl
| Download URL | ngt-2.8.0.post1-cp314-cp314-macosx_26_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.14 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
25e23f189d694235a520ebfeab914bfa9288a0f3b0e3612ccb8b7a994064120d
|
|
BLAKE2b-256 checksum How to use checksums |
c73373479f8014e577bfeae6617edb840674aae9e5676b23916165338c689f4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | ngt-2.8.0.post1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
052f76e7258c92c57e7198e8e6814014f18bc04acd39a3848477bcbc082f6335
|
|
BLAKE2b-256 checksum How to use checksums |
471e84ccdc3a524f3e42c8e0131cdb9ff455b392dc6f5901c541e1db3991a3ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ngt-2.8.0.post1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | ngt-2.8.0.post1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 11.5 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
fbeaf379c3787da920f8446aa9b84a3e30031f5bf88f92d3e681333a3b240e11
|
|
BLAKE2b-256 checksum How to use checksums |
8c147dc7e761f3683dd3923f289848e0757cb645a95e1e56f80be1dcd70a8191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp313-cp313-macosx_26_0_arm64.whl
| Download URL | ngt-2.8.0.post1-cp313-cp313-macosx_26_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8299d4001ff1869f81ddfa8556ab23b96a24525e7498a0e73257c8940e6bda7a
|
|
BLAKE2b-256 checksum How to use checksums |
347c2c9b3f117453e13989943ae7d47b670cf767eac444994264c7d2bc747bb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | ngt-2.8.0.post1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a6ccc11de8628ef4f5b3882a1518c6703fba14ce60cb2453a97fdf320cd3bb28
|
|
BLAKE2b-256 checksum How to use checksums |
80621d407e86c98f0e4286847b067ea842d83f029e149503dcec7d57a366f9ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ngt-2.8.0.post1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | ngt-2.8.0.post1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 11.5 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
68730f398cad3250d35af031059ece97d9cdc411b898b1ec332663e9b56b0c08
|
|
BLAKE2b-256 checksum How to use checksums |
ddebc83a4be0a285c9b86181a1123df1c41d023a5a65f13c4053065d10edd693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | ngt-2.8.0.post1-cp312-cp312-macosx_26_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
190a8c759dc1eb1495ae786c427ad0d61addff68f2c06f89f95635ca6eb48809
|
|
BLAKE2b-256 checksum How to use checksums |
650c956883270fe2a3756eb167b03b9fc357bed443a15c59bec50b1b9748c405
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | ngt-2.8.0.post1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
fbab7cd0a6b72a9a4bd018c436cfe3a25e5a043b53326bb9762e75d576e97802
|
|
BLAKE2b-256 checksum How to use checksums |
26858b771c4f3d3e4f74bc0dce63255c12d72d538c69709bfb87470ec62cb730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ngt-2.8.0.post1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
| Download URL | ngt-2.8.0.post1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 11.5 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
ae4c0c011dca5897685bcdbc10e86a908009dbda8e3dc400845f748dca115ddc
|
|
BLAKE2b-256 checksum How to use checksums |
795ff432096be0484f1f935a3ed7e4e555d0389b6aebc15ef52ad78f29c62afa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / ngt-2.8.0.post1-cp311-cp311-macosx_26_0_arm64.whl
| Download URL | ngt-2.8.0.post1-cp311-cp311-macosx_26_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
01b13984c1f0a90eec8e771a224cc5bca3db18095912c32af40db372141a7b1e
|
|
BLAKE2b-256 checksum How to use checksums |
ac34b2d03d042c6f5270c3be77eb876691e76ea33f12fe319f1de9764df97fa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|