Skip to main content

PyCyBase

tests docs pypi-linux pypi-windows gitlab

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

Uploaded CPython 3.15tWindows x86-64

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

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.6-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.3 MB view details)

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

pycybase-0.2.6-cp314-cp314t-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.14tWindows x86-64

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

Uploaded CPython 3.14Windows x86-64

pycybase-0.2.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.3 MB view details)

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

pycybase-0.2.6-cp313-cp313-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.2.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (8.3 MB view details)

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

pycybase-0.2.6-cp312-cp312-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.2.6-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.6-cp315-cp315t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.6-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.6-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 4cd29d4a0e1c68920a7167478e736f22dfa5aae23eb5ca6bbcbfb3efa9bd16d7
MD5 ca9d6263d7fda15581f6405e29b64523
BLAKE2b-256 6e4cf3e92f2112c22d2a97b113af47d5928ed433b3ac1dc0e3948a07200f1408

See more details on using hashes here.

File details

Details for the file pycybase-0.2.6-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.6-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 75b058e8d151f330a85cc13e0cae4f6a5c61581a763d5e4239e7444342941e3d
MD5 df430e45b5aa5c17a60c156e56d94ac8
BLAKE2b-256 49080095f3536b50ecdc9919260b573f0e09f1a83c3f5ec918fbaab01d31ed8e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.6-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.6-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 417f2d4bd557b6e7e721881a252b72ae0436a4605a2686dc75121bd592f2ec69
MD5 758da1eb2fbf9f7aeef89779eebc6393
BLAKE2b-256 2f81cb1aad65878660c8ec433356505a61601b26fcc40cb5247f6728ed2787d7

See more details on using hashes here.

File details

Details for the file pycybase-0.2.6-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.6-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b97f0f177e790261b3ec4a55a213d070c92974ccf4c415ad979cd5352b30eef4
MD5 11ad3af0d23e058de8f80ae245d53a07
BLAKE2b-256 2c7595e0c717a2f702050aa6966404ab8672d22abec2571124bffe4e747725b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.6-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.6-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 0a844aaf9b3193d707db6aa450852fc1791a16c259d078a20f98b41c64ce6dc8
MD5 0ff07666cafc5f3c2d87e56fc321e987
BLAKE2b-256 c500dbb423ebe23ce7cd7433d4edd3c5ef21fd91f521c80dba63974b7d6597ce

See more details on using hashes here.

File details

Details for the file pycybase-0.2.6-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.6-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09f21cf23b0500a4a1669d11f3ec94fcd2200078f21a7c76bbf0b7174bab1d5c
MD5 a8572ae1465ca33fe8269a9ccd26f65b
BLAKE2b-256 f39eb44c5debd940645ae02058b6a679ed8d2312043bc106ce3789711680e38a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.6-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.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b0eae1756a01d6474d0c861a797cc954325174d40d457308fc0a99b73433f84f
MD5 98b658909c63575401d02a405f2bb982
BLAKE2b-256 a230be0c6a75d234f140bb5c69847caece5685f048513453a55322a22c0819b4

See more details on using hashes here.

File details

Details for the file pycybase-0.2.6-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.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e603c98be4f487fd4a57e0ca6871383cab7bd431dccb929b886934a0703c9ba
MD5 904a3be1bb908fca65f8c725b401c0e4
BLAKE2b-256 70cfdfebcf4c51a83bf4f0ac020563b1a2d2179e0d2cf806ec1871fa9c1330b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.6-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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e6eab9e00d39f635b4d7e711908052373cf8d52c788664bad13a5919dd00f523
MD5 4f5f5caf631ce438d1beb20bb683a05e
BLAKE2b-256 f0178b6418de4eaa81232d1a317082fd3fb688179b416393991bdc80775003ad

See more details on using hashes here.

File details

Details for the file pycybase-0.2.6-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.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f67a609a50195f6d88b76508b1da9cfad392e8f945994071f8011c5ed8a39b49
MD5 887abce98f6dd284babf0551eb1f979e
BLAKE2b-256 48c4a1094be6a2a511fe6f1e29da09f139ba0fffdd0e765971e878904212602d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.6-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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2d27ffa2f7384da5821dd3b8d69ea74e840fcda190c55f9e9c05dcb39f86351e
MD5 1e71642cce3cca3366fa973067f986b4
BLAKE2b-256 6d8ffaffd542a29dcef378bdd4b965eda4e075ee6047443897f32646d0aecda0

See more details on using hashes here.

File details

Details for the file pycybase-0.2.6-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.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f76e973e1486dfe5706bae50bf87a7874e8ee532f042a0fb2aa63718837b5b6c
MD5 4c387451ef5318bc519a56045f608704
BLAKE2b-256 644bbf480a83ffff289fb373fe8363079d8083605bf58601e4a431c7cc71eb3b

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

This release

0.2.6 This release

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