Skip to main content

PyCyBase

gitlab

GitHub Actions: ⛔ temporarily disabled — kept disabled until the GitHub Actions issue is resolved. See .github/workflows/README.md. CI runs on the GitLab mirror pipeline while disabled.

Common C / Cython dual interfaces for Python HFT Projects.

Overview

Low-level allocator infrastructure shared across HFT projects:

  • Allocator Protocol — Pluggable memory allocation with heap, shared-memory (SHM), and raw malloc backends. Ref-counting, vigilant mode, thread-safety controls.
  • Heap Allocator — In-process allocator with free-list reuse and auto-growing pages.
  • SHM Allocator — POSIX shared-memory page allocator with fixed-address virtual region mapping for cross-process pointer stability.
  • ByteMap — Fast xxHash3-backed hash maps for string keys (ByteMap, ByteMapDouble, ByteMapSized, bound and view variants).
  • Intern String — FNV-1a-hashed string interning with SHM-backed cross-process pools. 1.7–2.2× speedup over Python str.

Quick Start

from cbase.allocator_protocol import AllocatorProtocol, AP_SHARED

with AP_SHARED:
    alloc = AllocatorProtocol(1024)
    alloc.buf[0] = b'x'
from cbase.intern_string import POOL

aapl = POOL.istr("AAPL")
assert aapl is POOL.istr("AAPL")  # Identity — string deduplication
from cbase.bytemap import ByteMap

bm = ByteMap(slot_capacity=16)
bm["ticker"] = b"AAPL"
assert bm["ticker"] == b"AAPL"

Build & Install

PyCyBase is a Cython extension package. Editable installs (pip install -e .) are supported: the build links the source tree into the environment's Cython/Includes, so downstream cimport cbase still resolves while you edit.

POSIX (Linux / macOS)

# Build extensions in-place, then install
./build.sh -i

# Or equivalently:
make build && pip install -U . --no-build-isolation

# Or step by step:
python setup.py build_ext --inplace --verbose --force
pip install -U . --no-build-isolation

Build script reference:

Command Effect
./build.sh Clean + build in-place
./build.sh -i Clean + build + pip install .
./build.sh -r Clean + build + force-reinstall
./build.sh -c Clean only (no build)
./build.sh -a Deep clean (remove .c and .so files)
./build.sh -l List all compile-time macros
./build.sh -v /path/to/venv Use a specific venv
make or make build Clean + build
make install Build + pip install .
make reinstall Build + force-reinstall
make list-args List compile-time macros

Windows (NT)

# Local build
.\build.ps1 -VenvPath "C:\Users\...\venv_313"

# Remote build (from Linux host):
python nt_build.py

Compile-Time Macros

Override any macro at build time via environment variable:

DEBUG=1 ./build.sh         # Enable debug mode
DEBUG=1 make build          # Same via Makefile

List all available macros and defaults:

./build.sh -l               # Auto-generates macros.json via probe.py
make list-args
python probe.py             # Run the probe directly

Key macros (see macros.json for full list):

Macro Default Description
AP_ALLOC_VIGILANT 1 Enable bounds/canary checks
AP_ALLOC_WITH_LOCK 1 Thread-safety via pthread mutex
AP_ALLOC_WITH_SHM 0 Default to SHM allocator
AP_ALLOC_WITH_FREELIST 1 Free-list reuse
AP_HEAP_AUTOPAGE_CAPACITY 64 KiB Default heap page size
AP_HEAP_AUTOPAGE_CAPACITY_MAX 16 MiB Max heap page size
AP_HEAP_EXACT_BIN_COUNT 8192 Exact 8-byte-granular free-list bins
AP_HEAP_LARGE_BIN_COUNT 9 Pow2-class free-list bins for large blocks
AP_HEAP_PAGE_EXTEND_MAX 128 MiB Max auto-page extension on bin miss
AP_HEAP_EXACT_BIN_PROBE_COUNT 2 Larger exact bins to probe before extending
AP_SHM_AUTOPAGE_CAPACITY 64 KiB Default SHM page size
AP_SHM_ALLOCATOR_DEFAULT_REGION_SIZE 128 GiB SHM virtual region
AP_SHM_EXACT_BIN_COUNT 8192 Exact 8-byte-granular free-list bins
AP_SHM_PAGE_EXTEND_MAX 128 MiB Max auto-page extension on bin miss

Using get_include() in Downstream Projects

from setuptools import setup, Extension
from Cython.Build import cythonize
import cbase

ext = Extension(
    "my_module",
    sources=["my_module.pyx"],
    include_dirs=cbase.get_include(),
)
setup(ext_modules=cythonize([ext]))

Cython Include Injection

A source install (pip install -U . --no-build-isolation or pip install -e .) calls cbase.cython_injection.inject_cython_includes from setup.py. It finds the target environment, checks that Cython is installed there, and links:

<site-packages>/Cython/Includes/cbase -> ../../cbase

Editable installs link the source tree; a wheel build links the installed copy, and a direct python setup.py build_ext --inplace does not inject. Built and published wheels ship a startup hook (_cbase_cython_link.pth) that creates the same link on the first interpreter start; it does nothing when Cython is not installed in that environment.

The same function is reusable from downstream packages such as PyAlgoEngine:

from cbase.cython_injection import inject_cython_includes

# inside a build_ext command, after super().run()
inject_cython_includes(
    "algo_engine",
    source="path/to/PyAlgoEngine/algo_engine",
    editable=self.inplace,
)

Calls return a status (injected, already-injected, conflict, skipped-no-cython, ...) instead of raising. The link lives outside the package tree, so pip uninstall leaves it behind; call uninject_cython_includes to remove it manually. See docs/cython_injection.rst for the full API.

Modules

Module Description
cbase.env EnvConfigContext — context manager for temporary config changes
cbase.allocator_protocol AllocatorProtocol, AllocatorConfigContext, AP sentinels
cbase.allocator_protocol.c_heap_allocator In-process heap allocator with free-list
cbase.allocator_protocol.c_shm_allocator POSIX shared-memory page allocator
cbase.bytemap.c_bytemap xxHash3-backed hash maps
cbase.intern_string.c_intern_string FNV-1a-hashed string interning
cbase.backports.pylong Python int ↔ 128-bit integer (uint128_t/int128_t) backport
cbase.backports.pydict PyDict_Pop backport for pre-3.13 Python

Documentation

pip install sphinx furo
cd docs
sphinx-build -M html . _build
# Or with the project venv:
~/Projects/venv_313/bin/sphinx-build -M html . _build

Open docs/_build/html/index.html.

Online: https://bolunhan.github.io/PyCyBase/

License

Proprietary.

Metadata

Release files for PyCyBase 0.2.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for PyCyBase 0.2.18
File Actions
pycybase-0.2.18-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details for pycybase-0.2.18-cp315-cp315t-win_amd64.whl
pycybase-0.2.18-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for pycybase-0.2.18-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pycybase-0.2.18-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details for pycybase-0.2.18-cp315-cp315-win_amd64.whl
pycybase-0.2.18-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pycybase-0.2.18-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pycybase-0.2.18-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for pycybase-0.2.18-cp314-cp314t-win_amd64.whl
pycybase-0.2.18-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pycybase-0.2.18-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pycybase-0.2.18-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for pycybase-0.2.18-cp314-cp314-win_amd64.whl
pycybase-0.2.18-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pycybase-0.2.18-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pycybase-0.2.18-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for pycybase-0.2.18-cp313-cp313-win_amd64.whl
pycybase-0.2.18-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pycybase-0.2.18-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
pycybase-0.2.18-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pycybase-0.2.18-cp312-cp312-win_amd64.whl
pycybase-0.2.18-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for pycybase-0.2.18-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Total release size: 81.0 MB

Release files / pycybase-0.2.18-cp315-cp315t-win_amd64.whl

Download URL pycybase-0.2.18-cp315-cp315t-win_amd64.whl
Size 4.4 MB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
8b6e4e7f1cfe8cda0d4f07e65348ac9c86c80713a60ff03d1086039b4f9c9aad
BLAKE2b-256 checksum
How to use checksums
d100d643020e3b3b987a7c9f5f1a4a7f4b56c80fe7110b831a38ed3dde641587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pycybase-0.2.18-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pycybase-0.2.18-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 9.2 MB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1d5ff3d5fb44a86f6cb7d07efce0942fc38b168ffab9b81e328bbf5fc770792d
BLAKE2b-256 checksum
How to use checksums
ba54ddb6c58a25db9bd91716e7be2189a7d5adea86a6578e77598b5ceff09ecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / pycybase-0.2.18-cp315-cp315-win_amd64.whl

Download URL pycybase-0.2.18-cp315-cp315-win_amd64.whl
Size 4.3 MB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
fc381e6d69504c1178a19aabda3dee9ab8cd9e70082749eeee6e05bf1e9cfe34
BLAKE2b-256 checksum
How to use checksums
d78ee7f30cfbc3798cee66c4c7c10961099d7d494649b3d89b65588266a3096b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pycybase-0.2.18-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pycybase-0.2.18-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags CPython 3.15 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
16e882724e2afde4119696f2ecbfd726de1551eaf4d0a24b11d04a2d70d5c645
BLAKE2b-256 checksum
How to use checksums
a7ec3c17931bc6d6448612037189634c734716714140f708814c8e2ece53de7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / pycybase-0.2.18-cp314-cp314t-win_amd64.whl

Download URL pycybase-0.2.18-cp314-cp314t-win_amd64.whl
Size 4.5 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
6d04e6a54a115054aefcd7b6f6a7e907344242ebde9284bf35b7d5aea7d6c05e
BLAKE2b-256 checksum
How to use checksums
ef963b2b77826cfd891e5f4afc7edcddcebd8bc987d1faa108c122e411e994a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pycybase-0.2.18-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pycybase-0.2.18-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 9.2 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cc41801da5cf2077a3173cca2cab4da795c8de31ad57880daf988cde7c35a480
BLAKE2b-256 checksum
How to use checksums
7467241a7b4d1735b3c7a969aff4007d6a735fa11b925f7dadf5182d264faa53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / pycybase-0.2.18-cp314-cp314-win_amd64.whl

Download URL pycybase-0.2.18-cp314-cp314-win_amd64.whl
Size 4.3 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
675afca6fabd31d56fa9eca2fc18e43d49070b5ece68cd799cc3acbb4f839ad1
BLAKE2b-256 checksum
How to use checksums
cb17104e46f6d5e29035ff4e813f3ad005eaee044327960e9b0d89655ab7d3f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pycybase-0.2.18-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pycybase-0.2.18-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1d66f3b1156bc309666601ec4cd83e3ebb41baef84bd6cfc054c990a0191826c
BLAKE2b-256 checksum
How to use checksums
35fb7dc4141817b5824283a5cc741cb52d6a52ba20a223b6197e0ecaf4c28022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / pycybase-0.2.18-cp313-cp313-win_amd64.whl

Download URL pycybase-0.2.18-cp313-cp313-win_amd64.whl
Size 4.3 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2b0deb19e91f648a7e275724b656516e6241107810523ec4ed3931835d3b2cf5
BLAKE2b-256 checksum
How to use checksums
381a6d9fd0da0feb654ca7c69ae29da65b2d1e6d94fc75a831ece250293ac722
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pycybase-0.2.18-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pycybase-0.2.18-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
691cde3053b09a23562a00525614cbf4681b2ca643bd9a9ff453c497cb3c15b7
BLAKE2b-256 checksum
How to use checksums
7edebbd4ba5fc9f3074aeb8dc14e9a3d479e5606348f9b18090299bb0697e121
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / pycybase-0.2.18-cp312-cp312-win_amd64.whl

Download URL pycybase-0.2.18-cp312-cp312-win_amd64.whl
Size 4.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
58f779f1cfa150133c32b4cec7e5269d1248f3c7d8999b7d6a26adf120ce42a3
BLAKE2b-256 checksum
How to use checksums
3848a69fba3063f2d36d949a50dd4215258e75dc546c4abf0389ec1b1ad2532a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / pycybase-0.2.18-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL pycybase-0.2.18-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f151a4bcd202ebc17e41a47b3d8adba62d49c2aeb2142c6698e0842a35362531
BLAKE2b-256 checksum
How to use checksums
93cf615e0812301876788b2e8021b8941b25020bfbf63524b8804e2e39bccffc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for PyCyBase 0.2.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.18 This release

12 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page