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

Uploaded CPython 3.15tWindows x86-64

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

Uploaded CPython 3.15Windows x86-64

pycybase-0.2.0-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.0-cp314-cp314t-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.14tWindows x86-64

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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

pycybase-0.2.0-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.0-cp315-cp315t-win_amd64.whl.

File metadata

  • Download URL: pycybase-0.2.0-cp315-cp315t-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.0-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 4da549378bf0480434222c0e3dbe518e7933b6a16508fe87ec6ed9c53945880a
MD5 0605e16e9ac8a8869e908a60ff020b51
BLAKE2b-256 469d5882b7bf4f436872b5a27dedffe8eba7f6c5a2572efcd3ce7d147a783ff0

See more details on using hashes here.

File details

Details for the file pycybase-0.2.0-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.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5d112da08baaeebc1b33a0b4a31f3c9b7193294d93e9094bdc5a78f82f8f0b6e
MD5 ca7f03fd76817645e00e33e18c89f92d
BLAKE2b-256 2650001cdf6f0df53d9aad6e2bf6b4e7c09e4879aa0e5c79b0e392a55de88fb6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.0-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.0-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 2261abc4b87905026514068678327ba6d625c92861e611381c721e1a1ee56068
MD5 7735fd4db25410efcb113a190ce2f4a0
BLAKE2b-256 55e554abed6631c8ae88f00f0f45851d35dbe3f2d8bc65159c98674910cc5831

See more details on using hashes here.

File details

Details for the file pycybase-0.2.0-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.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5e61fea0a330dd9a8553ddb913677447e8de6d7de3f3f5eb551e448d1963314
MD5 7ab29c93de57fa4a6023c2eff6efd131
BLAKE2b-256 ee815294d663d0cd3de2d65ac74c33e1502fd845ef6e0a415a1eb6193d4cd161

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.0-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 e28f8d85daaed4a41dc16e9377b17c721c8656715235505bbf50090f80149571
MD5 79524837d331457121c4a3b4fc327f66
BLAKE2b-256 5f230faf040cc863a843f19319484c4ae35d9e318964bbb7d1b341e8c8472d7f

See more details on using hashes here.

File details

Details for the file pycybase-0.2.0-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.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9469a9b32e5a35f8772f6cb63ebb713006e3149ed4e6c1dc903ec54aab60f07b
MD5 c09b666afbd67ef387999f07613e02f4
BLAKE2b-256 22ce71a4969435cea2875bfd435a4d26ed9d79074ebfa0d24fe30b897a1d713f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.0-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.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 60b35d86999c7442e20428d0f0aa02da7308565d3ec9ca07d62fffe452fcd6b1
MD5 48d70ef5fed85a54ebc9d16e96d4d5ae
BLAKE2b-256 021449f2cca97329a3b66c7299d1f9c1458ac83298cdbc8d79a662a789f5ea47

See more details on using hashes here.

File details

Details for the file pycybase-0.2.0-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.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ceda712b23ffcaec0498c07d10cb059bea19712965f0f7c89004831d59b54484
MD5 bf5f70e8a796ad04b5991a583440bebf
BLAKE2b-256 9afdb4845b3bd02c117dafed1ebddc93677ec3d592f1d4772ad0e240130adc3f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.0-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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a7343fcedd6c4519c2f368acb0b2ded8a281a28ec7fdf07e11549a178ad859e5
MD5 5ce920e0cddcd759071835c989b60631
BLAKE2b-256 e26af136f0269937aa01990429401d3c3780194d328e7f74d59dc1889b6d1dfe

See more details on using hashes here.

File details

Details for the file pycybase-0.2.0-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.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c64c356df06cc4c68e945bb4ac2dac970ea03e48bc71b5839108026a99d64edc
MD5 1f0fc155264323046a9c590e28aa3a2e
BLAKE2b-256 8b3465cd529ebaa0f68c0771480722e889e3fae8bfabe3977f775ac253096cf7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycybase-0.2.0-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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 64521cf2e0035213928aa8167f30257f39d309a47b6430beac308468a7be157a
MD5 950ff5b15550ec2d14da47e834670775
BLAKE2b-256 dbc841ffc2260ca1d01a43236038b3a24457ae9e4de214ed927795c6a64fad8f

See more details on using hashes here.

File details

Details for the file pycybase-0.2.0-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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5806e40c46eb51c929534477fa00e5da0d00ebd23fb2ee88f9eb9018cb5b27a5
MD5 f30466ca9313b6fac645f8fb5428709c
BLAKE2b-256 4aa59d411ffc82c28d83b580998048b0523e13b65a0d9359545f9e631075fae2

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

This release

0.2.0 This release

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