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 byte-string keys (ByteMap, ByteMapEx, bound 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()
bm[b"ticker"] = b"AAPL"
assert bm[b"ticker"] == b"AAPL"

Build & Install

PyCyBase is a Cython extension package — it cannot be used with pip install -e . (editable mode breaks Cython .pxd resolution for downstream projects).

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]))

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycybase-0.2.9-cp315-cp315t-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.15tWindows x86-64

pycybase-0.2.9-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.15tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pycybase-0.2.9-cp315-cp315-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.9-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.15manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pycybase-0.2.9-cp314-cp314t-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.14tWindows x86-64

pycybase-0.2.9-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pycybase-0.2.9-cp314-cp314-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.2.9-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pycybase-0.2.9-cp313-cp313-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.2.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pycybase-0.2.9-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.2.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pycybase-0.2.9-cp315-cp315t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.9-cp315-cp315t-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.15t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pycybase-0.2.9-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 a49d585986a908ec35d60937ea0b2ef8e8409cfd859e795bfcadd4e1e3199af8
MD5 dc921950f4c374b3c0c17931971cf4b2
BLAKE2b-256 4e07a671b68d34e08d0e00e53b1c911bb7be27348a772e20aff54df7286cd9de

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycybase-0.2.9-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3443301c4b40b91ed615dff2f4ab0418f53dda38c4e70d8dbc7bf628731ab895
MD5 1ed7d38e6654439e15eb39e9d518965f
BLAKE2b-256 0bd5ab83de488745f1ba2234d8fae6dc01306b76b278aeea070f91c700694f59

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp315-cp315-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.9-cp315-cp315-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.15, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pycybase-0.2.9-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 02280ff625cb597af4087e70e8b21c8c90dfaf7f1f48d3de21333d08a0e3c7a5
MD5 22399834a9ba0ceee6b270b09b58dbfe
BLAKE2b-256 890fed288e9f5bae6adc65fcd8e492ab165c7819514fa4bcad8e537b2590e84a

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycybase-0.2.9-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f546658267de89d591d9417cb046d43ba6ffda512f59ae0432be9c84ba78b8f
MD5 835ff2f462c3d0885a8f0662800896b0
BLAKE2b-256 d9da2c17692dc6a759c05af20b531a1146dc66afd9a3fccf6ba62ed2e26a614f

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.9-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pycybase-0.2.9-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 90a0915e450a0902921fc5931552bb2cfec927f373e8472823b9f829b044b1fd
MD5 e5a85739fc5ac72a13d0efe8cbcdb983
BLAKE2b-256 7d11e749494be58fc40f4e8601a178b63602769e4efba2aaf8b03be837dbd8b4

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycybase-0.2.9-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b611c8516e01e78337b551615e6d0fe84f1c9d104fe14a4c3934e8b6c57600d
MD5 e99de8f873d87e5a588a20a79958bfae
BLAKE2b-256 effb54db28b0b6be20092557537d3a3af0b9acbc20ba660bbb430374e27d29c7

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.9-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pycybase-0.2.9-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2cdb60906907b9b92c873c95d73fe740c49c9f82fb0b8781167542274b10c495
MD5 a9777958b4a016274d4167f2da6145a2
BLAKE2b-256 23feb090f4318ddd09e1881e76f157eabfc5ef855948f638ef648573a4c31a06

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycybase-0.2.9-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5916cce12b9f85a69d34dbb62a30c04dc506fdb0966d0910f1d5d01f0f6425e8
MD5 17dc5d75956bf922b8b321e272212103
BLAKE2b-256 e5260e557570b72485393a78055f518ff70677ba61dcb45aa71506d77b1a37c9

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pycybase-0.2.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 55df9420a8c76c331fa30033a0146b201ec54b5f6727184b30adaab5ebe9a84c
MD5 85917393acea97690b8c086d222bd28e
BLAKE2b-256 e61b28af77243aec984e06024c442ad72c2c1120a2a90ab5e4067c303129959c

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycybase-0.2.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d23cb9a67b3e2641c8fb4cf3f0224c6006d6231c5c0579c138d4167f3dfb36a8
MD5 b27229ad950e7b0b5637ebe32e951f84
BLAKE2b-256 c5ae4641d0c7ca9f08b26bcdbb4cba24df75ae1c2e005c62ce6d3c7f1f1bc194

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pycybase-0.2.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b5576deb0426c0578b3070a4930abba95508734bfe7db21ef356b026b543e413
MD5 bc08cb1cba9a2da235b04863538ff564
BLAKE2b-256 d408fd3e622e856c9c097a67a89369ada3ace8a9b0e7fa68ecc7d2d09d2aac16

See more details on using hashes here.

File details

Details for the file pycybase-0.2.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycybase-0.2.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 33f53977006c14b52941c5390ca21edbf224a90bda928ec03036ac20d170d286
MD5 9599182a2194f35dbe9dbbb78290642c
BLAKE2b-256 4cd80513ca4a46bc502b60c144d3b2b032e85ba784443d8a3655e6c77f3db886

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.9 This release

12 files

0.2.8

12 files

0.2.7

12 files

0.2.6

12 files

0.2.5

12 files

0.2.2

12 files

0.2.1

12 files

0.2.0

12 files

0.1.11.post1

12 files

0.1.11

12 files

0.1.10

12 files

0.1.9

8 files

0.1.8.post5

8 files

0.1.8.post3

4 files

0.1.8.post2

4 files

0.1.8.post1

4 files

0.1.8

4 files

0.1.7.post4

4 files

0.1.7.post2

3 files

0.1.4.post2

4 files

0.1.4.post1

4 files

0.1.3.post1

4 files

0.1.0

4 files

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