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

Uploaded CPython 3.14tWindows x86-64

pycybase-0.1.9-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.9-cp314-cp314-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.1.9-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.9-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.1.9-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.9-cp312-cp312-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.1.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (6.4 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.9-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.1.9-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 3.0 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.9-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 e6509cf2f1d6d6a1cb9904f0076aa163623f7281e34072b3e88ff5ea6e90c7ec
MD5 303fa2d7f2e5c4a6704adb8e4332c837
BLAKE2b-256 84ae4b264f64a55d1279a2edb6dec67e83bf786960cda602184c1fdfdd7766d1

See more details on using hashes here.

File details

Details for the file pycybase-0.1.9-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.9-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8aed78032848f9bcf95803efc2a2e1b8713c1e818b72c47897834cf7c201b40a
MD5 636fef2d8ae32789de835890348cf111
BLAKE2b-256 f6a09ce5b028c751e63cf12614b368f971eafcc04c708a6597610fa4f525278b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.1.9-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 3.0 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.9-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c9151c562051731d7c537f4932503e463f6b33e373eee78f109bceb53d99a21c
MD5 b5b20001abb8d556b15de0bc3b115cea
BLAKE2b-256 9df59637646ddafbfd171b3bd2c05938fd450511c9d9f34a410af3cd0bb06d7b

See more details on using hashes here.

File details

Details for the file pycybase-0.1.9-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.9-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f741e8e0bff32fd73ede4b97ff47c5a3ce88ea53a8950626549ec22ca5492f05
MD5 3d8b05e4a6ea1ed4a758896ee6115615
BLAKE2b-256 8f49ccfcb80a78d3b1095a479da5b03e5aee37772bf55cc6dac7c2fca2d4ce1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.1.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.9 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.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f9fd1fbab26dcecbed258e60f17a4d385ada9248ba36401f0c05173fa0907c06
MD5 70204d1a7b26cfae7871356d409ad750
BLAKE2b-256 75c6e72a13088e3327f50c1b057451ba8be2f9f286c99e2677eb4573363f45b7

See more details on using hashes here.

File details

Details for the file pycybase-0.1.9-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.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 51e2265101bf4c256334c48636a83bff9aa500232a8ddc412f02915b46c116ab
MD5 9afcd9ca3f1df14eff6a417e154180d6
BLAKE2b-256 8d48d4b755eeba57d0f2f990794b52afe7c161e527a632072724f3b80796ed2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.1.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.9 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.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2fcb18209633e86a772419bf48fae394bf9f92666d00b40a5c35c837c814eda1
MD5 01cbeb680d026bf7175aaa88318a7f04
BLAKE2b-256 d31af715b34ace7189acf3ed1b66c9a0ffbf5ddaee5a19866af897c2e3ad54c2

See more details on using hashes here.

File details

Details for the file pycybase-0.1.9-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.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cd3090d5533a8c12015195e81ff9cfa8d4e13324a6e7471f29f4ea404dadcf27
MD5 9041efd7bfb13fe28a594a30f7995c52
BLAKE2b-256 bce9d306c24571dd4dcf9728b17dd3bb8ffc31b28d881f76301626872582a863

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

This release

0.1.9 This release

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