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

Uploaded CPython 3.15tWindows x86-64

pycybase-0.2.1-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.1-cp315-cp315-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.1-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.1-cp314-cp314t-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.14tWindows x86-64

pycybase-0.2.1-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.1-cp314-cp314-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.14Windows x86-64

pycybase-0.2.1-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.1-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

pycybase-0.2.1-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.1-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

pycybase-0.2.1-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.1-cp315-cp315t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.1-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.1-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 d32a9a6f4d16de6154ff09dc4ae452a6103ffda74f84c451d1fe17a80f2fa560
MD5 60e3cef367a3a6c7e06f9794c6ea53c9
BLAKE2b-256 b3a996a2fb969f77d8869d05489f99272b642520027a4268a704835394f09a20

See more details on using hashes here.

File details

Details for the file pycybase-0.2.1-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.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8bb4808087e03707c53a69d0c2c5fa28708e1632b6f46db335cd32d53f98d974
MD5 7ec2253c38975a93effde985bc9848aa
BLAKE2b-256 31365b98f46193406d099b7b207a3ec5baa7e31adb243e43d0d6e9cab7e38a78

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.1-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.1-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 20e73f5a96dd478f8ba0a7730627381294cce77420fcd59968fd693fa441b141
MD5 e8e1883a476fd60739ab85dea28ad2f2
BLAKE2b-256 5d4e0150e796eedb0b45042d1862bd448ca0647128cf2c4b1e39e38af50d7103

See more details on using hashes here.

File details

Details for the file pycybase-0.2.1-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.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6b541cb447089f89d71af0d2ef36e07ec5f40cfe750c8a93d77a1d5abf387ebd
MD5 e0171808d8c35f2bb0d155959f243fe3
BLAKE2b-256 76d07258bffd34add1cb1e48903156167d26e58077c2c33c3bfe737570b72f1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.1-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.1-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 ed08d25b3263bca9078f96fd3f7669c93b874fff8fbe6e0533f60c5f140a188c
MD5 0d3aa76d4ca02bc7d56a4633bcc5ecd7
BLAKE2b-256 a9caa838bcc3441ca205af45fb658ad861b504f3c21e4656646da2b291af846a

See more details on using hashes here.

File details

Details for the file pycybase-0.2.1-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.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac3424c875f12d4c9c11bbc4e5a594a8ddc34ca5546a1638e554d6c6eca2d716
MD5 d4d075d83f405f2411708fd85bd1e405
BLAKE2b-256 5210560fabcc45f4d4ac73d2362de36661e4e18c82bcf4e727d1d0015015a7bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.1-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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 000c81e77bbe97cd3e16f7c3b9e299e43b73ea408e324d87b380c2e94fd7ff56
MD5 0343d1f548c0ae8b2e4fad5f91a0b39a
BLAKE2b-256 2121f49ef6006369dc850ccda1db848f80ee8a2463ccd1a70cf2aa5574b7a678

See more details on using hashes here.

File details

Details for the file pycybase-0.2.1-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.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c123c0e24321a8172d3753cab06a1ac662f2a02ecb5201ad4d1abaeabeaea62b
MD5 90b2bb8a9ea05a093cc0cbc6708fdb82
BLAKE2b-256 197ac208bc45a80850b45bf163d3037a2e832ae2246c7f8132071184731afcb8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.1-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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f3f1051f435ac68c7f2993140856c872a0214a847f84549d9c756d3821c5bb4c
MD5 7dcf39910f01e6ea4c090811b0da8a01
BLAKE2b-256 2523c44f19c98d3a9ead3c93915d9a796bf67c6e6cea29572c82b6552845544a

See more details on using hashes here.

File details

Details for the file pycybase-0.2.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb511ca0df0fef2ddcdacdcd0e1e54c562784b41bda49e694e0336abebf043da
MD5 6951aa87246ef3810b61a4a5ff5db3f6
BLAKE2b-256 34517d374e5e4153917ff21f7d3887e85cfa038c7c78a2a00937b167576aecb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 149bd8d09a63352d75230b5d770bc5e64251746d055ba00a08faa8a05cafb6c9
MD5 54965aeacfc89aeb445ae6d476f2610d
BLAKE2b-256 b62a33ba94eead5e91070b08e7345e46476322625b6ca43e88a27bc5025fee61

See more details on using hashes here.

File details

Details for the file pycybase-0.2.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1729c9f51f441d2d670f8325ec370c4318a101b95fe9c9217668b4d4f9fd191d
MD5 01950e191566b586f3a63f4ffbbee669
BLAKE2b-256 7200f54391fb9c1663d2f3e8c3d4e23fd64c4311c18321224923798d8d885e02

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

This release

0.2.1 This release

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