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

Uploaded CPython 3.15tWindows x86-64

pycybase-0.2.8-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.8-cp315-cp315-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.8-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.8-cp314-cp314t-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.14tWindows x86-64

pycybase-0.2.8-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.8-cp314-cp314-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.2.8-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.8-cp313-cp313-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.2.8-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.8-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

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

File metadata

  • Download URL: pycybase-0.2.8-cp315-cp315t-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.8-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 3dac22db4c2b3e1f6b7cde87591c42ea7f1bfa48525cd8f0ef4b9755cfcb1206
MD5 e390e290d0c0fac678f701c1a859570d
BLAKE2b-256 f17c7ddc8bc74a0954a2ea268f9077d5fd46b45fbd1669be69a63623205d7bd3

See more details on using hashes here.

File details

Details for the file pycybase-0.2.8-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.8-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14114702ce68fc0992ae5fe956a25d39d8c8b8d6370260a94656aa261784812b
MD5 41adbd7382ec0f9cd6a342834046f0e9
BLAKE2b-256 5ed4753858f7e420d4fd0d17a55109a892574ae4b9b017256510d271cf27b6f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.8-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.8-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 4d3fa3552803b38932a3b75560525229759a463dd0a3f4055cadf0fcb9bc8fb3
MD5 f46e7b5ae3f562b9ec2ff4f3c0c95a0d
BLAKE2b-256 c2c07b713b7ac03b332edf4228585d3905368dd9cacbed9537cdf3b5bdff7cbd

See more details on using hashes here.

File details

Details for the file pycybase-0.2.8-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.8-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2100b1a43587cd59875c3e03ebd8e39b21551332b4a448a5af39c91a2a3a9593
MD5 eac079d1c993aa146a4024b4f93cd118
BLAKE2b-256 ec6f7a011419432be8e3616829c863b034ee56ed21c694ea867ab0b3c63ff075

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.8-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 4.1 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.8-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 0fc9c84d4898008d69ecbe464dc6d3233d7cd498d1d29b6f96235666e1732f6a
MD5 369573a26000c1d9ea3125b2e1374e4c
BLAKE2b-256 dc9770c69a529dd020a68a424a07d9e69234e24f927d033c8551b82e04f18b16

See more details on using hashes here.

File details

Details for the file pycybase-0.2.8-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.8-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e1b7e83c4ee0d166151e1286823e15b17d9af3847db68b4add8f0320776255d
MD5 e15288a24db41b3992d34cdd5d4b9947
BLAKE2b-256 adf5fc94ce5fe50d6cf0bfa80fa43a5fff35e4152374771fc2afa5db6fa22151

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.8-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.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 fdc78fc89817a0cc325eb243ede9d0125abe33505d64c8e62cc7a67cde028735
MD5 f75bf36ef2f55ea0bbd76b2cc4b9c731
BLAKE2b-256 b1d5fa68bedd2306c47236f13f77d9807c7b798ca69d1f5e0b3a1337beaafb3c

See more details on using hashes here.

File details

Details for the file pycybase-0.2.8-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.8-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 807b52828efa80a84a842a288d893ab223d9c7d50e1e136e12f22ed69cbb0523
MD5 756f95f4460fc79aae6340f7a07bc65e
BLAKE2b-256 c1a3708882d9573d4338ff0953f2b8f78071cc819ac1df22c85fca9013a7fb09

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.8-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.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8b5c508d218908607de51f1d7c5d741ee5531031fe150212f6a948f1f8790c09
MD5 04aab7c8d343886bca4256972957fdf6
BLAKE2b-256 f2547b0f63198f4f68265aa28beceb17883afb32fffd16b6e91be1e3433529fc

See more details on using hashes here.

File details

Details for the file pycybase-0.2.8-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.8-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 41d370854f04e14f7aa17840074e6eb77d1a19083f5cf8d38127c31ad4fb1e81
MD5 fbae8f55346489f8afc26a23a4a4f890
BLAKE2b-256 fc6e301ea0b062cdf92ca186c932f81d2e91d7e929297dfc76c66d5b091559e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.8-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.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 61aeaddf68af178be043241d0fb380d50b3319bc2357e8a4cd0bde8c51bf76a8
MD5 9ee12e5745ba75d1d0c3920c5d3f6ba3
BLAKE2b-256 47ea0fdf00cb24a35dd8d8f783c9afb4a55bdb550577ac37fef6418431b56be4

See more details on using hashes here.

File details

Details for the file pycybase-0.2.8-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.8-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 54577478157b54fda028dcdc27f874e47f86f3f6a39c3c11ce03514355fdbe14
MD5 a98ec912edb268fece22b8ed62782ef2
BLAKE2b-256 059f215b4dec215cde94af653ef3526734d340b3d4fb151a0dbd51d399386e86

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.9

12 files

This release

0.2.8 This release

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