syNumpy is a standalone C++17 library from Symisc Systems for reading and writing NumPy .npy files.
Project homepage and documentation: https://pixlab.io/numpy-cpp-library
syNumpy is used internally by Symisc/PixLab production systems.
- It is used by FACEIO for internal facial features extraction workflows.
- It is used by PixLab document and visual search workloads behind the DocScan Mobile App and StreetLens mobile app integrations built on top of the PixLab API Endpoints ecosystem.
- It also integrates naturally with the DOCSCAN ID Scan API, which is designed to scan and extract structured data from identity documents worldwide.
- Single public header and single implementation file:
synumpy.hppandsynumpy.cpp - C++17 API with no external runtime dependency
- Core parser centered on
syNumpy::loadNpyBuffer() - Load
.npyarrays from disk or directly from a memory buffer - Save typed vectors and raw buffers to
.npy - Append mode for extending the first dimension of an existing array
- Strict validation for malformed headers, truncated payloads, and unsupported dtype/layout combinations
This public release focuses on robust .npy support.
- Supported: scalar numeric and complex NumPy dtypes that map cleanly to native C++ types
- Supported: shape metadata, payload loading, file loading, memory-buffer loading, and append-on-axis-0
- Supported: explicit dtype-based raw save through
syNumpy::saveNpyRaw() - Not implemented in this release:
.npzarchive support - Endianness is validated explicitly; cross-endian payloads are rejected rather than silently byte-swapped
synumpy.hpp: public C++ APIsynumpy.cpp: implementationexample.cpp: minimal usage sampleCMakeLists.txt: CMake build integrationMakefile: simple Unix-style build integration
The easiest way to integrate syNumpy is to drop synumpy.hpp and synumpy.cpp directly into your codebase and compile them as part of your project. No complex build scripts, generators, or external runtime dependencies are required.
cmake -S . -B build
cmake --build build --config ReleaseTo install:
cmake --install build --config ReleasemakeThis builds:
build/libsynumpy.abuild/example
To install:
make installMSVC:
cl /std:c++17 /EHsc /W4 synumpy.cpp example.cppGCC or Clang:
c++ -std=c++17 -O2 -Wall -Wextra -Wpedantic synumpy.cpp example.cpp -o exampleInclude the public header:
#include "synumpy.hpp"The main entry points are:
syNumpy::NpyArraysyNumpy::loadNpyBuffer()syNumpy::loadNpy()syNumpy::saveNpy()syNumpy::saveNpyRaw()
#include "synumpy.hpp"
#include <cstdint>
#include <fstream>
#include <iterator>
#include <vector>
int main() {
const std::vector<float> values = {1.0f, 2.0f, 3.0f};
syNumpy::saveNpy("floats.npy", values);
syNumpy::NpyArray loaded = syNumpy::loadNpy("floats.npy");
std::vector<float> roundtrip = loaded.asVector<float>();
std::ifstream input("floats.npy", std::ios::binary);
std::vector<std::uint8_t> bytes{
std::istreambuf_iterator<char>(input),
std::istreambuf_iterator<char>()
};
syNumpy::NpyArray from_buffer = syNumpy::loadNpyBuffer(bytes.data(), bytes.size());
std::vector<float> in_memory = from_buffer.asVector<float>();
return 0;
}See example.cpp for a fuller sample covering:
- file save/load
- memory-buffer loading
- append mode
- shaped matrix output
The C++ interface is intentionally small and source-oriented. The public declarations live in synumpy.hpp, and that header should be treated as the immediate source of truth during integration.
This README does not attempt to fully document every API detail. For project updates, integration notes, and the official documentation path, use:
- FACEIO for passwordless facial authentication
- DocScan Mobile App for document, receipt, sign, and ID scanning workflows
- PixLab API Endpoints for the broader developer platform
- DOCSCAN ID Scan API for scanning passports, driver licenses, national IDs, visas, and other identity documents from around the world
BSD 3-Clause. See the LICENSE file.