Skip to main content

PyCyBase

tests 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_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.5-cp315-cp315t-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.15tWindows x86-64

pycybase-0.2.5-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

pycybase-0.2.5-cp315-cp315-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.5-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.2 MB view details)

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

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

Uploaded CPython 3.14tWindows x86-64

pycybase-0.2.5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

pycybase-0.2.5-cp314-cp314-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.2.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.2 MB view details)

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

pycybase-0.2.5-cp313-cp313-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.2.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.2 MB view details)

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

pycybase-0.2.5-cp312-cp312-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.2.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.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.2.5-cp315-cp315t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.5-cp315-cp315t-win_amd64.whl
  • Upload date:
  • Size: 4.0 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.5-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 b8787c354fb02dd074230ff2aef390a6b8651a5707b2b532a2f4b61de9eefa63
MD5 2853cf84eb6028329f9de0390758a062
BLAKE2b-256 79ee5ca6b999be993deb2236cb2b04ab80af879a515258ddb7faedea0b4e28b3

See more details on using hashes here.

File details

Details for the file pycybase-0.2.5-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.5-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b759becc0940d40aaf6f2d83a0d598a4890e30a9e55944a1778a05912b8a0cf
MD5 c131ab0c1e6b16fb31493fe00c5d4769
BLAKE2b-256 9169962e11ef02423e4b67e302e025709cf2695516eca09f747cf93b7f9abb23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.5-cp315-cp315-win_amd64.whl
  • Upload date:
  • Size: 3.9 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.5-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 29ea9f94db58f6ecb04038d618ec59b6edf9a5008e230ce06f7b9d3b1d20b391
MD5 f14d8463cdf800936a7824e64dc75f5a
BLAKE2b-256 b9a5ba5540725ba76822be58dcf7539f312605a16e6339efb6454b766c276776

See more details on using hashes here.

File details

Details for the file pycybase-0.2.5-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.5-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd12fa7d45c401a99f09459b82feb8e395bf67a1f0c252875b78c8f259951b63
MD5 87b4acced783547ad8ecf0a8a8a88757
BLAKE2b-256 71aed88b5e5ef6c7abe80dd20bc8d98ec6a63bba7b60e49cc5e1aa8f5acd842a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.5-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 4.0 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.5-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 66fbf8c2110968117f3cb49f9f497b5742db95562ea7a38a9e13e58da2719f00
MD5 27a0db9f6277416e3cf7a1a7a6876210
BLAKE2b-256 44b160f5356af7d7acb8d99e4247d4fd19b3d119b32fc228aa159e65378cefec

See more details on using hashes here.

File details

Details for the file pycybase-0.2.5-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.5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57ec641538451184ac23b035d3780cadb9afb3b7c0b5c667d07b48d7f289f5f7
MD5 f17b70759b5da59e789596bfeff73778
BLAKE2b-256 8764ba40d3104a1359f01a9d71c206842559684a223b3e3afcd2bcf054753f55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 3.9 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.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8e8a53d95ef04e43111f6760d9de0cded619068ad350e245d8a3152b459129c0
MD5 db6387363f8657a03719580bf986671e
BLAKE2b-256 d691e81c45d501ef14164556b545f82c353b000da55386f39c134df1d091ecd7

See more details on using hashes here.

File details

Details for the file pycybase-0.2.5-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.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d9dff3922d10bb7767a2f6a491eeabb27b87ee5cd88d1a9c72f6d85ed2d5153
MD5 f307e677df1fd115b220a91ab87a196f
BLAKE2b-256 268dbd4b3dc4649a16c489041e90d3fcb988950fd1fa56f87526b71d8299a6fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.9 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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a5c7e0a7179bc2afbce59f0114ffb6172a0e661f84ec0b79636ec993b3933a4c
MD5 d5ff83ce93b4a18cef42b17b2a351d3d
BLAKE2b-256 1ad30b764a13d6daa9a06f0d6a190cb76459a908b0fae2e327c75a5ced2b4bfb

See more details on using hashes here.

File details

Details for the file pycybase-0.2.5-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.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d0a0d770041e19556a77a82f9a58c22462cce6f130476bd628058f73c2027df
MD5 83fbd15546f1916996478abe89fbb0a3
BLAKE2b-256 60a63cdbf6d0d185faec08c86314daa82e9ff51dd3fab44634c543cecce9eeb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.9 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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c29ba2b89210cf01f09feb9cba0f887e218b4b4a3bf01f63a3aa6d135e95b46f
MD5 0cf40ad64ea204c9b21d664d25933495
BLAKE2b-256 0f7b780d436993a53b9ffea16358c3b43fbf513b43f9fe40c65944b511e64093

See more details on using hashes here.

File details

Details for the file pycybase-0.2.5-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.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8c6e344338f2d4d1873e3b33436c7d46be44e015221ffb9e81c09ac2fb562e0f
MD5 e8e782c981a3b9d22c2d1664ac989eaa
BLAKE2b-256 0699a539a343c08de5ca25391b2962cefdea1f2fe518a0a89fd8f6eb5f86941c

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

This release

0.2.5 This release

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