Skip to main content

PyCyBase

docs pypi-linux pypi-windows

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_SHM_AUTOPAGE_CAPACITY 64 KiB Default SHM page size
AP_SHM_ALLOCATOR_DEFAULT_REGION_SIZE 128 GiB SHM virtual region

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.1.8.post5-cp314-cp314t-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.14tWindows x86-64

pycybase-0.1.8.post5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.4 MB view details)

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

pycybase-0.1.8.post5-cp314-cp314-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.1.8.post5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

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

pycybase-0.1.8.post5-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.1.8.post5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

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

pycybase-0.1.8.post5-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.1.8.post5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.3 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.1.8.post5-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 38dfc5a96198d765a01ccdc097f534bd3f2b54007aa979b63981230615f33401
MD5 783c779109f1e69e670b3ee6073a1e9e
BLAKE2b-256 2449f88e86e1e9315c6390d8c6da6db9961c2a53c3a7e0b76d6a9e7fd25f9752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 415f107b0a8b9a62a47dbcbaa3d59b2bc791976ed20fae1a8ef868f91170dd3b
MD5 afab1123933757af344eda1a1c4a29a7
BLAKE2b-256 617d1f6762f7f886ad43f5effce20a0e8c7b93c4f22b868bbf1cdc11254f12c7

See more details on using hashes here.

File details

Details for the file pycybase-0.1.8.post5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c0222ee4efd77bfe21cd531536cb505b4f0f13271ea9f3626a36bfdfec10eb3c
MD5 280ab4d22618e108d6815426783ceef6
BLAKE2b-256 057e223615c01131a5b8ef3a83646c709501019fee0e4594c46c8374bde54669

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70500d87dd3ac36aa190c4d1b3010257b23e56adeca092fe616cf8fc77bca1af
MD5 b6ff4a3ea3f872946d3f9a0ceb9adab1
BLAKE2b-256 f2f8cc61de694c21082d8c59f87fca85e7fd55f3a22c73d5defa19ae232493b1

See more details on using hashes here.

File details

Details for the file pycybase-0.1.8.post5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e9dc119f8366460f552aed9f6d5f1759a49e0821efb5197008464358d2a7a013
MD5 023f631125aca1f3fe6e4f4917c77597
BLAKE2b-256 b7134758e6a435e490cd79b9ed5b684f54a5a305811db3244de9f66d8d6627c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d5dec55b9489be1eeee9cfbcc4766dfe542e6de3fdb62b697bbdb6f83f7c98c
MD5 4c7e0de7a04d1cb8666af69c734d5eaa
BLAKE2b-256 dae3e08e66e4852a85415e1c159dc62c9db1a14f1628fc6c54fd88d22f1d6f25

See more details on using hashes here.

File details

Details for the file pycybase-0.1.8.post5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f480f1f106c8a728c4ee8f35d0086f73afd34adf60354b3a5351a77ce12aa595
MD5 5854e196012a8a1fb85cc30d523ca8ed
BLAKE2b-256 9e2811e60afb74c515c2740e124189ce5669a8f5e6a885fe7a1e5320fe352564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycybase-0.1.8.post5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e41ba64819f037eb98f15f7e16d587df423a7873188633db9ab62976b546cc7
MD5 8e0f3409d549c3d6e6c7e147f4cb44d9
BLAKE2b-256 9dd2de686ced2aa3c95ab9edeeff2dd1e43d8f0891ec1db87189727e3e880c2c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.9

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

This release

0.1.8.post5 This release

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