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.2-cp315-cp315t-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.15tWindows x86-64

pycybase-0.2.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.4 MB view details)

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

pycybase-0.2.2-cp315-cp315-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.3 MB view details)

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

pycybase-0.2.2-cp314-cp314t-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.14tWindows x86-64

pycybase-0.2.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.4 MB view details)

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

pycybase-0.2.2-cp314-cp314-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.2.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.3 MB view details)

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

pycybase-0.2.2-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.3 MB view details)

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

pycybase-0.2.2-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (7.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.2-cp315-cp315t-win_amd64.whl.

File metadata

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

File hashes

Hashes for pycybase-0.2.2-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 962c20be8733a069ab037280c030a3eaee142ef76d78442a61118471693f9e95
MD5 c797c9d506e71d36eb5ece04311c8abd
BLAKE2b-256 3510fe1c554c3938d1071a4529599cc164f280df474fd276b71ae2c5edb0f841

See more details on using hashes here.

File details

Details for the file pycybase-0.2.2-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.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e20e9b7dcfb190790f7320ee79f11ea561ef57bd01d163dbc9502e9d1bb0d7d
MD5 10bea877a262be415659f549dcba1ad9
BLAKE2b-256 8751072455bf0a905e01b87d7ae2b13783732a60c905001764f098065bf522c6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.2.2-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 abcf9ee45dfc451c8ad84373135b1772bf6d14461799922147367f45700f3549
MD5 28eaf8614f2756e7ebf5c7982c9b02d0
BLAKE2b-256 b89cce17ca1f742d8794461f355f8b334c7a119fa46fd83484b51252013709bc

See more details on using hashes here.

File details

Details for the file pycybase-0.2.2-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.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 87dad9f1e5f460fe433771050fd3a2dec06bffb9535f37b203a4fdcb2461a4e8
MD5 47ed157b3263131eb5a926fc835aa82b
BLAKE2b-256 58cfe6d30dc148d9a099df0b63dd3d7b4dde55e462737504c5c2038e0a7c3941

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.2.2-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 915eb01300a18a914727290ccca83270591f84a114181c289004ed2ffaf30d0b
MD5 ab95298de5c17d12908ef22417adca41
BLAKE2b-256 c6925a9743290df7b0199f530ae10ffecac94d6365384c01b2a1222bb22bcdf2

See more details on using hashes here.

File details

Details for the file pycybase-0.2.2-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.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6c9f5e729eaf525275e1cab81096ae2eb292e6399a54e9627460c90303e3f262
MD5 262ab477b8fa33d35f98ef6af897210a
BLAKE2b-256 12c82971058e68e066ae20872314f5d02ab7b726e9fb9222ae91fee5164f117a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.2.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 7cb85b876b9ab0d0322df899beb06009d31b590e5398e1212cd177a2ff6caf33
MD5 57b3f4be05b31c9e5ebdae6cf941e86b
BLAKE2b-256 6114ab1091089934d1c194225760ab8bc821a09aa053ccec2edce41e86345006

See more details on using hashes here.

File details

Details for the file pycybase-0.2.2-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.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 13ff61b210464afb0d9985a47827837e5582b7c3ca10d41c8a812f56e39789ca
MD5 c448cdf0f72f64e1e816cddee07a199c
BLAKE2b-256 8992d42188b854ed2f341b33c6fecee57bfefa532c45faa3425147e59e3b946d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.2.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 913bcafe0171b008a6c56ca9dbc128aaf9235ff1e02f470363be9d34acb599c6
MD5 570bcc811f6bef85d5e9cc347d03927f
BLAKE2b-256 aa310b6b445119537476e14b3c24d65c41e660af9553890b0a93a05af19bd6dc

See more details on using hashes here.

File details

Details for the file pycybase-0.2.2-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.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b4f32725b4751f5b218cdc9beada41dad423a4b3fb23656aeb9b2f1c241f43c
MD5 230d418296cd584d4369777d7b33e6c9
BLAKE2b-256 ac8a04bee134ca8c6b7913460b23986afc90c1eb95bf2f439fcb9e39ba70aea2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycybase-0.2.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b95fcd3958b4a58a91aead36312d9481363f33ee46d364f3ff57d0395a984079
MD5 54ec37cb4957dce48aa9fe3037845717
BLAKE2b-256 245d773a2bc9e78d69948ccbcb80a644642692940d236ea4dd9146370e300909

See more details on using hashes here.

File details

Details for the file pycybase-0.2.2-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.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1b40700053c3bf04654d11f45a54cae0856c160a581428b53930f4e6125805b1
MD5 d6ba8f5c04017eba807d355d81fe4428
BLAKE2b-256 2afb7b03da3308fa9796eff59a53a172e54db01a3c7e87f3a6d6f5fd6c07ef84

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

This release

0.2.2 This release

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