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_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.1.11-cp315-cp315t-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.15tWindows x86-64

pycybase-0.1.11-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

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

pycybase-0.1.11-cp315-cp315-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.15Windows x86-64

pycybase-0.1.11-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

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

pycybase-0.1.11-cp314-cp314t-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.14tWindows x86-64

pycybase-0.1.11-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

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

pycybase-0.1.11-cp314-cp314-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.1.11-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.0 MB view details)

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

pycybase-0.1.11-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.1.11-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.0 MB view details)

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

pycybase-0.1.11-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.1.11-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.1 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.11-cp315-cp315t-win_amd64.whl.

File metadata

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

File hashes

Hashes for pycybase-0.1.11-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 82547a4efaebd8001080f4792a145d1fc31b6428260ffc62205126d4a9b82bdf
MD5 4fc94110e8f83d829e12997789f57026
BLAKE2b-256 aadc0622ad828a208d125ce9c9bf905a612baf5595c3d905a464a69e9942b7f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycybase-0.1.11-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66f0d11c8c6afa3f927f29f81309fb09c79106645587ed7e1c446d4421137908
MD5 1bbf48730af3e9d3375fbde5a1e4f556
BLAKE2b-256 ca1bd88320566d9aa2fd2dd3810a315b77f58f13a9872557c28665c72ce37a6d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.1.11-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 625059999db07bdfeba21217c693556a21f77640bd3c2d9a2a50c40bbe7e2611
MD5 0da81a92b57df9a9b2cccd67018a71dd
BLAKE2b-256 45f9a2916316c6bad12641e56a3634158c2ac79836b5fbbc4a44555fb3122d7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycybase-0.1.11-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a0951fd2ea6d35ca177c380bcb7fae10836b57cba61972c31495211b7ecdf2f
MD5 b7ecbed56aa7ea33c751e1062be6041f
BLAKE2b-256 62b5b545b3d23016b237ff1c59925ab98a4863e926dadb715126d1b9b00ff583

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.1.11-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 5d9a592d54713858444c26058089e273a965f7bdbbb54d5bba74c2fc8feab720
MD5 5067e7d48f9b23402de4947beb13f794
BLAKE2b-256 c3ea7669d583de18b728fe581f88560f6f99c83ed34795b6b971143de838c803

See more details on using hashes here.

File details

Details for the file pycybase-0.1.11-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.11-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f1083fecf80afdd746dafce12f7df4a40ad2ecd19bc8b1c037c62a44b1f9f058
MD5 5dd5b1ffb04356e9d81e0b9c75d81ea3
BLAKE2b-256 26f8ab4e2cf2e52cfc99be19e90364991fb07ca22b5cde51459d6e91a619d914

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.1.11-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ba06bc5bdd637f4b0fd14ca6371c3e24eba4010d819f5fe3c7d1b2f1a0a52783
MD5 6bd3750fb56cdf3433b57d78cbb48a08
BLAKE2b-256 f648a06d94a3dfeec8a4b91c66c5b8eb5c8de56a48c90fd14f44f36265a990c8

See more details on using hashes here.

File details

Details for the file pycybase-0.1.11-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.11-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4eae84e3a0c6506e3ce2d3a4d6c5fbf1d315c30e65cd8e11cdb0e8c9b5984a35
MD5 a9136ae7bedd3e8dbf50bc0ee1e1f868
BLAKE2b-256 abc0e4f6347fe96ede79586a77e34084253567564b13ce38f90a23f89422857b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.1.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ef14dce2d5819f3cbb529ac1d94a577697e86e904e0e4850fbbe60970c5f09aa
MD5 816428ed171837a5d7197c00a9fa8b05
BLAKE2b-256 7bd9764fe64d2a455ac0983b548a026cb8c6a728c9cfe6eba8962073e318e86a

See more details on using hashes here.

File details

Details for the file pycybase-0.1.11-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.11-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc4a15fef7fc9c98d331aa2c4404339a8633bde1fe33e56914d9a2d51b93e89b
MD5 c378a3abad1a07ec75e40d8ab2eb36ce
BLAKE2b-256 6fbb507123c2ab130c68930db81df299bbafc79eb8871a59bdc6583e9d6384c6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.1.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0a14f508788b1d9f2c61eabf42b53beb05048c060b1908dcf12b02bd152a0f6a
MD5 b387fd6efa9b69ba10ea26e573a28063
BLAKE2b-256 852df00db14d9eae2bfa59fff2ce8857b486dc2f85569f3796bfc7bb597bb584

See more details on using hashes here.

File details

Details for the file pycybase-0.1.11-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.11-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 53edb4785118ed1fb1215e30f7c57ac6f343c258e7ef157956c607c6ed135513
MD5 52455ba8679a21e90f61b3e8c8131c54
BLAKE2b-256 4afd54188261a94bbb9928597f404b4fa1f3f10fbcf9a7cf37e218d40d07ccce

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

This release

0.1.11 This release

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